【问题标题】:How to rewrite the request to sub-folder to another application in IIS如何将子文件夹的请求重写到 IIS 中的另一个应用程序
【发布时间】:2017-01-17 17:01:34
【问题描述】:

如果用户请求http://my.example.com/pages/uc?dc=qXE7kHEIHHiT2Gexv%2bLDy63yqTeh3gcHsd%2bBrn6vn4%2bArW0gmwv8nw9

那么应该重写为http://qa.example.com/uc?dc=qXE7kHEIHHiT2Gexv%2bLDy63yqTeh3gcHsd%2bBrn6vn4%2bArW0gmwv8nw9

用户应该看不到 URL 的变化(用户永远不应该知道它是一个不同的应用程序)

【问题讨论】:

    标签: iis url-rewriting url-rewrite-module


    【解决方案1】:
    <system.webServer> 
        <rewrite> 
            <rules> 
                <rule name="Route the requests for pages" stopProcessing="true"> 
                    <match url="^pages/(.*)" /> 
                    <conditions>
                        <add input="{CACHE_URL}" pattern="^(https?)://" /> 
                    </conditions> 
                    <action type="Rewrite" url`enter code here`="{C:1}://www.qa.example.com/{R:1}" /> 
                     <serverVariables>
                        <set name="HTTP_ACCEPT_ENCODING" value="" /> 
                    </serverVariables> 
                </rule> 
            </rules> 
            <outboundRules> 
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1"> 
                    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://www.qa.example.com/(.*)" /> 
                    <action type="Rewrite" value="/pages/{R:2}" /> 
                </rule> 
                <rule name="RewriteRelativePaths" preCondition="ResponseIsHtml1"> 
                    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" negate="false" /> 
                    <action type="Rewrite" value="/pages/{R:1}" /> 
    
                </rule> 
                <preConditions> 
                    <preCondition name="ResponseIsHtml1"> 
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 
                    </preCondition> 
                </preConditions> 
            </outboundRules> 
        </rewrite>
        <urlCompression doStaticCompression="true" doDynamicCompression="false" /> 
    </system.webServer> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 2023-04-07
      • 2020-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多