asp.net - UrlRewrite 2.0 not removing www from url in IIS 8.5 -
i've these 2 rules in web config file force https , remove www url.
<rule name="remove www" stopprocessing="true"> <match url="^(.*)$" /> <conditions> <add input="{http_host}" pattern="^(https?://)?www\.(.+)$" /> </conditions> <action type="redirect" url="{c:1}{c:2}" redirecttype="permanent" appendquerystring="false"/> </rule> <rule name="redirect https" stopprocessing="true"> <match url="(.*)" /> <conditions logicalgrouping="matchall" trackallcaptures="false"> <add input="{https}" pattern="off" ignorecase="true" /> </conditions> <action type="redirect" url="https://{http_host}{r:1}" redirecttype="found" appendquerystring="false" /> </rule>
note: i've gone through questions here on , blogs no luck yet :(. of posts as;
proper method remove www address using iis url rewrite
http://madskristensen.net/post/url-rewrite-and-the-www-subdomain
http://www.serverintellect.com/support/iis/url-rewrite-to-redirect-www-iis7/
http://www.bradymoritz.com/iis7-url-rewrite-remove-www-from-all-urls/
....
make sure putting rules in web.config under system.webserver - > rewrite -> rules.
this should job you:
<system.webserver> <rewrite> <rule name="redirect https" stopprocessing="true"> <match url="(.*)" /> <conditions> <add input="{https}" pattern="off" /> </conditions> <action type="redirect" url="https://{http_host}/{r:1}" /> </rule> <rule name="remove www" patternsyntax="wildcard" stopprocessing="true"> <match url="*" /> <conditions> <add input="{cache_url}" pattern="*://www.*" /> </conditions> <action type="redirect" url="{c:1}://{c:2}" redirecttype="permanent" /> </rule> <rewrite> </system.webserver>
Comments
Post a Comment