Looking to remove a particular query string parameter. Folder name can be different and length of the specs param can vary with any combination of numbers. Whenever there is a specs parameter, regardless of the value, strip that parameter and redirect to http://example.com/folder
Example Inputs:
http://example.com/folder1?specs=10,13,14,18,20,29http://example.com/folder2?specs=14,18,20Would redirect to (respectively):
http://example.com/folder1http://example.com/folder2Do not strip any other query string params. i.e.
http://example.com/folder1?page=1 would not get redirected.
Rule Tried, not working, despite seeming like it would when using the IIS rewrite rules test tools:
<rule name="SpecsSpiderCrawl" stopProcessing="true">
<match url="(\/\/.*\/)(.*)\?" />
<conditions>
<add input="{QUERY_STRING}" pattern="specs=.*" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:2}" appendQueryString="false" redirectType="Permanent" />
</rule>
I was making it too hard. This worked:
<rule name="SpecsSpiderCrawl" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{QUERY_STRING}" pattern="specs=.*" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:0}" appendQueryString="false" redirectType="Permanent" />
</rule>
{HTTP_HOST} is just the example.com portion of the uri{R:0} will get the folder nameappendQueryString="false" will remove the entire query string (which is fine for my use case.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With