Quantcast
Viewing all articles
Browse latest Browse all 27852

Conditional outbound tag rewriting rules

I need to generate an outbound IIS rewrite rule which looks at A and FORM tags. Any A or form tag that does NOT contain /string(.*) needs to be written.

So for example if I had:

<a href="/string/foo.html">link</a> - that would not be rewritten because it contains /string

If I had:

<a href="/news/foo">link<a> - that would get written

I have the following outbound rule defined but it seems to be matching all links not just those that don't contain /string(.*)

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

I'm not sure using a condition with {URL} is the right approach. Would someone be able to assist me with crafting the right rule?


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>