asp.net - IIS URL Rewrite working in one page only -
i have defined url rewrite rule through iis. turns this:
article.aspx?id=1&friendlyurl=whatever into
/1/whatever please note redirection working right, url rewrite (links within page) not being translated unless inside article.aspx page.
how can make rewrite rule apply pages instead of one? i'm posting below written rules web.config reference. thanks.
<system.webserver> <rewrite> <outboundrules> <rule name="outboundrewriteuserfriendlyurl1" precondition="responseishtml1"> <match filterbytags="a, form, img" pattern="^(.*/)article\.aspx\?id=([^=&]+)&(?:amp;)?friendlyurl=([^=&]+)$" /> <action type="rewrite" value="{r:1}{r:2}/{r:3}/" /> </rule> <preconditions> <precondition name="responseishtml1"> <add input="{response_content_type}" pattern="^text/html" /> </precondition> </preconditions> </outboundrules> <rewritemaps> <rewritemap name="article rewrite"> <add key="article.aspx?id=1&friendlyurl=whatever" value="/1/whatever" /> </rewritemap> </rewritemaps> <rules> <rule name="redirectuserfriendlyurl1" stopprocessing="true"> <match url="^article\.aspx$" /> <conditions> <add input="{request_method}" pattern="^post$" negate="true" /> <add input="{query_string}" pattern="^id=([^=&]+)&friendlyurl=([^=&]+)$" /> </conditions> <action type="redirect" url="{c:1}/{c:2}" appendquerystring="false" /> </rule> <rule name="rewriteuserfriendlyurl1" stopprocessing="true"> <match url="^([^/]+)/([^/]+)/?$" /> <conditions> <add input="{request_filename}" matchtype="isfile" negate="true" /> <add input="{request_filename}" matchtype="isdirectory" negate="true" /> </conditions> <action type="rewrite" url="article.aspx?id={r:1}&friendlyurl={r:2}" /> </rule> </rules> </rewrite> </system.webserver>
so had hard-code links url-friendly setting "href" attribute within code.
something this:
<a href='/1/hello-world/'>read "hello world" article</a> thanks.
Comments
Post a Comment