简体   繁体   中英

How to rewrite the request to sub-folder to another application in IIS

if user request to http://my.example.com/pages/uc?dc=qXE7kHEIHHiT2Gexv%2bLDy63yqTeh3gcHsd%2bBrn6vn4%2bArW0gmwv8nw9

then it should be rewrite to http://qa.example.com/uc?dc=qXE7kHEIHHiT2Gexv%2bLDy63yqTeh3gcHsd%2bBrn6vn4%2bArW0gmwv8nw9

The user should not be able to see the URL changes (user should never know its a different application)

<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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM