asp.net - IIS URL Rewrite issue with Tilde (~) -
i have legacy urls need redirect have tilde (~) part of url. i'm having issues getting iis rewrite rules work.
old url: http://www.example.com/~/media/something/whatever.pdf
need redirect to: /whatever
i have following rules in place:
web.config
<rewrite> <rewritemaps configsource="rewritemaps.config" /> <rules configsource="rewriterules.config" /> </rewrite>
rewritemaps.config
<rewritemaps> <rewritemap name="legacy urls"> <!--does not work--> <add key="~/media/something/whatever.pdf" value="/whatever" /> <!--works--> <add key="/testing123" value="/whatever" /> </rewritemap> </rewritemaps>
rewriterules.config
<rules> <rule name="redirect rule1 legacy urls" stopprocessing="true"> <match url=".*" /> <conditions> <add input="{legacy urls:{request_uri}}" pattern="(.+)" /> </conditions> <action type="redirect" url="{c:1}" appendquerystring="false" /> </rule> </rules>
i'm thinking must need escape tilde, perhaps html encode: ~
( http://www.ascii.cl/htmlcodes.htm ) or url encode.
otherwise must interpreting ~ differently, la application home.
Comments
Post a Comment