asp.net mvc - iis7 url rewrite for webforms aspx to mvc page -
i have had website /contact.aspx
gets succesful redirect /contact
want redirect old /content.aspx?contentid=123
/about/123
here redirect xml part in web.config:
<rewrite> <rules> <rule name="contact" patternsyntax="wildcard" stopprocessing="true"> <match url="contact.aspx" /> <action type="redirect" url="contact" redirecttype="found" /> </rule> <rule name="content" patternsyntax="wildcard" stopprocessing="true"> <match url="content.aspx?contentid=*" /> <action type="redirect" url="about/{r:1}" appendquerystring="false" redirecttype="found" /> </rule> </rules> </rewrite>
visiting mydomain.com/content.aspx?contentid=123 gives me 404. tried without appendquerystring="false"
seems easy fix me, missing something...
using regex instead of wildcard gives 404:
<rule name="content"> <match url="content.aspx?contentid=([0-9]+)" /> <action type="redirect" url="about/{r:1}" redirecttype="found" /> </rule>
from iis rewrite module configuration documentation.
the url string evaluated against pattern not include query string. include query string in rule evaluation can use query_string server variable in rule’s condition.
so after big of test jiggery-pokery, think should work:
<rule name="content" patternsyntax="ecmascript" stopprocessing="true"> <match url="content.aspx" /> <conditions> <add input="{query_string}" pattern="contentid=([^&]+)" /> </conditions> <action type="redirect" url="about/{c:1}" redirecttype="found" appendquerystring="false" /> </rule>
Comments
Post a Comment