0
votes

I have installed URL rewrite module on the IIS 8.0 and configure rules

  1. If user come without www and it will prefix www
  2. If user comes from http then it will redirect to https
  3. If user comes from mobile browser than it sends to mobile website

Below are the 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 and WWW prefix to 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 to 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 is done when user come from mobile browser. I redirect to https://www.website.com/en-mobile but when I do like this https://m.website.com/en-mobile it gives error but when I browse manually it works very good. So how can I redirect to that url when people come from https://www.website.com to https://m.website.com/en-mobile

1
any reply will be appreciatedMilind

1 Answers

0
votes

I could solve this issue may be it will help to somebody so I am adding my solution over here. I change Mobile Redirect rule action to

<action type="Redirect" url="https://m.website.com/en-mobile" appendQueryString="true" redirectType="Found" />

Putting redirectType to found solves my issue.