iis - Canonical Redirect on the server only -
i can redirect domain.com-s on www.domain.com , it's working on server charm:
<rewrite> <rules> <rule name="canonical host name" stopprocessing="true"> <match url="(.*)" /> <conditions> <add input="{http_host}" negate="true" pattern="^www\.domain\.com$" /> </conditions> <action type="redirect" url="http://www.domain.com/{r:1}" redirecttype="permanent" /> </rule> </rules> </rewrite>
but has 1 side effect - working when on testing environment, on localhost , redirects on production server.
how possible add condition work on server only?
this can achieved using second condition requesting host domain.com
sub-domain:
<rewrite> <rules> <rule name="canonical host name" stopprocessing="true"> <match url="(.*)" /> <conditions> <add input="{http_host}" pattern="domain\.com$" /> <add input="{http_host}" negate="true" pattern="^www\.domain\.com$" /> </conditions> <action type="redirect" url="http://www.domain.com/{r:1}" /> </rule> </rules> </rewrite>
(note missing \
in condition , redirecttype="permanent"
optional)
Comments
Post a Comment