Quantcast
Channel: URL Rewrite Module
Viewing all articles
Browse latest Browse all 2482

Redirect when query string does not match a pattern

$
0
0

Hello,

I need to redirect to another website when the query string is anything other than a couple of values, or if there is no query string at all.

i.e.

https://www.mydomain.com/?pageid=55 - no redirect (should not match the rule)

https://www.mydomain.com/?pageid=155 - no redirect (should not match the rule)

https://www.mydomain.com - redirect to http://myotherdomain.com 

https://www.mydomain.com/?pageid=4 - redirect tohttp://myotherdomain.com 

Here is my rule:

<rule name="query redirect" enabled="false" stopProcessing="true"><match url="(.*)" negate="false" /><conditions logicalGrouping="MatchAny" trackAllCaptures="false"><add input="{QUERY_STRING}" matchType="Pattern" pattern="pageid=155$" ignoreCase="true" negate="true" /><add input="{QUERY_STRING}" matchType="Pattern" pattern="pageid=55$" ignoreCase="true" negate="true" /></conditions><action type="Redirect" url="http://myotherdomain.com/" appendQueryString="false" redirectType="SeeOther" /></rule>

However, this doesn't work, it redirects me to http://myotherdomain.com no matter what the input is, despite the pattern passing the checks in the GUI.

Any help greatly appreciated.


Viewing all articles
Browse latest Browse all 2482

Trending Articles