2
votes

We are using IIS URL Rewrite module to redirect all request from a mobile browser to m.mymobilesite.com by checking HTTP_USER_AGENT. This works fine and now we need to implement a "View Full Site" link which will allow the user to see the main site. Trying to achieve this by adding a "nomobile" cookie when user clicks on "View Full Site" link which will be validated and negated by the rule. For some reason my rule doesn't seems to work.

Please help.

<rewrite>
<rules>
    <rule name="MobileRedirect" patternSyntax="ECMAScript" stopProcessing="true">    
        <match url=".*" ignoreCase="true" />
        <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_COOKIE}" pattern="nomobile" ignoreCase="true" negate="true" />
            <add input="{HTTP_USER_AGENT}" pattern="android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" />
        </conditions>    
        <action type="Redirect" url="http://m.mymobilesite.com" appendQueryString="false" redirectType="Found" />
    </rule>
</rules> </rewrite>
1

1 Answers

0
votes

The rule is perfect and I figured out the issue after doing a trace on failed request at IIS level as described here

The cookie which I was creating while user select the "View Full Site" link was not created with the domain name. I added domain="mymainsite.com" on the cookie creation script and it is working fine now.