I'm really new to rewriting urls and trying to rewrite / redirect multiple requests, but it doesn't seem to work. Since this is a search result and runs with different filtering, the queries may differ. For example, in some searches we may have the query t1=something , and in another - t2=somethingelse , and sometimes we can combine them as: t1=something&t2=somethingelse
Im using IIS7 with web.config, and here is what I have done so far:
This is my example link
www.website.com/search/?t1=first&t2=second
I tried the following, and not one of them actually worked:
(one)
<rewrite> <rules> <rule name="first" stopProcessing="true"> <match url="search/" /> <conditions trackAllCaptures="true"> <add input="{QUERY_STRING}" pattern="t1=([0-9a-zA-Z]+)" /> </conditions> <action type="Redirect" url="search/{C:1}/" appendQueryString="false" /> </rule> <rule name="second" stopProcessing="true"> <match url="search/" /> <conditions trackAllCaptures="true"> <add input="{QUERY_STRING}" pattern="t2=([0-9a-zA-Z]+)" /> </conditions> <action type="Redirect" url="search/{C:1}/" appendQueryString="false" /> </rule> </rules> </rewrite>
(2)
<rule name="a" stopProcessing="true"> <match url="search2/" /> <conditions trackAllCaptures="true"> <add input="{QUERY_STRING}" pattern="t1=([0-9a-zA-Z]+)" /> <add input="{QUERY_STRING}" pattern="t2=([0-9a-zA-Z]+)" /> </conditions> <action type="Redirect" url="search2/{C:1}/{C:2}" appendQueryString="false" /> </rule>
I would really appreciate any help.
Thanks.
url-rewriting iis-7 url-rewrite-module
Jay
source share