On my website, I have a situation where my URL sometimes get a querystring parameter appended by a system outsite ours.
So instead of looking like this: http://www.domain.com?myquery=blah
or http://www.domain.com
, it has the url http
: http://www.domain.com?myquery=blah&theirpara=blah
or http://www.domain.com?theirpara=blah
.
When a user visits with the "theirpara" parameter, I would like to make a 301 redirect to the URL without it.
I've tried using the URL rewrite module, but not really getting anywhere. It would be nice to do it at IIS/web.config level instead of Response.RedirectPermanent if possible.
I thought it would be good to setup up using a rule (URL write module), but to be honest, I've no idea how to fix this issue. I am using the following rule to remove the trailing slash, but not sure how to modify it to this need.
<!--To always remove trailing slash from the URL-->
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
Any ideas on how to set it up?