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?
{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/…