url rewriting - URL rewrite on IIS 8.0 -
i have installed url rewrite module on iis 8.0 , configure rules
- if user come without www , prefix www
- if user comes http redirect https
- if user comes mobile browser sends mobile website
below rules
<appcmd> <config config.section="system.webserver/rewrite/globalrules" path="machine/webroot/apphost" overridemode="inherit" locked="false"> <system.webserver-rewrite-globalrules> <rule name="mobile redirect" enabled="true" patternsyntax="ecmascript" stopprocessing="true"> <match url="^$" ignorecase="true" /> <conditions logicalgrouping="matchany" trackallcaptures="false"> <add input="{http_user_agent}" pattern="android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" /> <add input="{http_x-device-user-agent}" pattern="midp|mobile|phone" /> <add input="{http_x-operamini-phone-ua}" pattern="midp|mobile|phone" /> </conditions> <servervariables> </servervariables> <action type="redirect" url="/en-mobile" appendquerystring="false" /> </rule> <rule name="add https , www prefix website.com" stopprocessing="true"> <match url="(.*)" /> <conditions logicalgrouping="matchall" trackallcaptures="false"> <add input="{https}" pattern="^off$" /> <add input="{http_host}" pattern="^website\.com" /> </conditions> <servervariables> </servervariables> <action type="redirect" url="https://www.website.com/{r:1}" appendquerystring="false" /> </rule> <rule name="add https www.website.com" stopprocessing="true"> <match url="(.*)" /> <conditions logicalgrouping="matchall" trackallcaptures="false"> <add input="{https}" pattern="^off$" /> <add input="{http_host}" pattern="^www\.(.+)$" /> </conditions> <servervariables> </servervariables> <action type="redirect" url="https://www.website.com/{r:1}" /> </rule> </system.webserver-rewrite-globalrules> </config> </appcmd>
in above first rule mobile redirect done when user come mobile browser. redirect https://www.website.com/en-mobile
when https://m.website.com/en-mobile
gives error when browse manually works good. how can redirect url when people come https://www.website.com https://m.website.com/en-mobile
i solve issue may adding solution on here. change mobile redirect rule action
<action type="redirect" url="https://m.website.com/en-mobile" appendquerystring="true" redirecttype="found" />
putting redirecttype found solves issue.
Comments
Post a Comment