Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the following outgoing IIS URL rewrite rule:

        <outboundRules>
            <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="true">
                <match filterByTags="A, Form" pattern="^(travel.*)" negate="true" />
                <action type="Rewrite" value="http://www.traveldomain.com/{R:0}" />
            </rule>
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>

Basically IIS is configured to act as a reverse proxy. Requests come in, they're proxied to a backend server and then before they're returned to the end user I need to modify any links not containing /travel...[anything else] to come from a different domain (www.traveldomain.com)

The rewrite rule seems to be triggered but if my link started out as /foo for example it gets rewritten as www.traveldomain.com instead of www.traveldomain.com/foo

In other words {R:0} isn't being appended as I expect. I've tried {R:0} as well as {R:1} - neither seems to work. What am I doing wrong?

Edit

I'm somewhat closer with this rule

<outboundRules>
            <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml" enabled="true">
                <match filterByTags="A, Form" pattern="^/(.*)" />
                <action type="Rewrite" value="http://www.traveldomain.com{R:1}" />
            </rule>
            <preConditions>
                <preCondition name="ResponseIsHtml">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules> 

but this re-writes ALL urls and I want to rewrite just urls that do not contain /travel...

Perhaps I need to add some statements but I'm not sure how I would say A or FORM elements don't contain contain travel?

share|improve this question
    
Try {R:2}? This link suggests the R:x is based on the condition pattern matches so not sure if that needs to be adjusted? iis.net/learn/extensions/url-rewrite-module/… –  Brock Hensley Apr 18 '13 at 21:07
    
{R:2} also doesn't appear to work. I believe to use R:2 you'd have to have multiple regex's in parenthesis (R1)(R2) –  Brad Apr 18 '13 at 23:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.