arthurh88
asked on
IIS URL Rewrite syntax
I have a URL I want to rewrite:
A. www.mysite.com/oldproducts --> www.mysite.com/master/default.aspx?state=all
B. www.mysite.com/oldproducts/ --> www.mysite.com/master/default.aspx?state=all
One has a trailing slash, the other doesn.t
How do I put this into a rewrite without using 2 rules? This rule I have will work for A but doesn't work for B
<rule name="ProductsRoot" stopProcessing="true">
<match url="^oldproducts/$" ignoreCase="true" negate="false" />
<action type="Rewrite" url="master/default.aspx?s tate=all" appendQueryString="true" redirectType="Permanent"/>
</rule>
A. www.mysite.com/oldproducts --> www.mysite.com/master/default.aspx?state=all
B. www.mysite.com/oldproducts/ --> www.mysite.com/master/default.aspx?state=all
One has a trailing slash, the other doesn.t
How do I put this into a rewrite without using 2 rules? This rule I have will work for A but doesn't work for B
<rule name="ProductsRoot" stopProcessing="true">
<match url="^oldproducts/$" ignoreCase="true" negate="false" />
<action type="Rewrite" url="master/default.aspx?s
</rule>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx
? means 0 or 1 time for the item before it.:
EG oldproducts and oldproducts/
? means 0 or 1 time for the item before it.:
EG oldproducts and oldproducts/
ASKER
would it be better then to use /?$ to make sure nothing comes after the one or zero times of /
ASKER
learned something new! Thanks Kyle :)
ASKER