title: URL rewrite on IIS 8.0
body: <p>I have installed URL rewrite module on the IIS 8.0 and configure rules </p>
  
  <ol>
  <li>If user come without www and it will prefix www</li>
  <li>If user comes from http then it will redirect to https</li>
  <li>If user comes from mobile browser than it sends to mobile website</li>
  </ol>
  
  <p>Below are the rules </p>
  
  <pre><code>&lt;appcmd&gt;
      &lt;CONFIG CONFIG.SECTION="system.webServer/rewrite/globalRules" path="MACHINE/WEBROOT/APPHOST" overrideMode="Inherit" locked="false"&gt;
          &lt;system.webServer-rewrite-globalRules&gt;
              &lt;rule name="Mobile Redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true"&gt;
                  &lt;match url="^$" ignoreCase="true" /&gt;
                  &lt;conditions logicalGrouping="MatchAny" trackAllCaptures="false"&gt;
                      &lt;add input="{HTTP_USER_AGENT}" pattern="android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" /&gt;
                      &lt;add input="{HTTP_X-Device-User-Agent}" pattern="midp|mobile|phone" /&gt;
                      &lt;add input="{HTTP_X-OperaMini-Phone-UA}" pattern="midp|mobile|phone" /&gt;
                  &lt;/conditions&gt;
                  &lt;serverVariables&gt;
                  &lt;/serverVariables&gt;
                  &lt;action type="Redirect" url="/en-mobile" appendQueryString="false" /&gt;
              &lt;/rule&gt;
              &lt;rule name="Add HTTPS and WWW prefix to website.COM" stopProcessing="true"&gt;
                  &lt;match url="(.*)" /&gt;
                  &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="false"&gt;
                      &lt;add input="{HTTPS}" pattern="^OFF$" /&gt;
                      &lt;add input="{HTTP_HOST}" pattern="^website\.com" /&gt;
                  &lt;/conditions&gt;
                  &lt;serverVariables&gt;
                  &lt;/serverVariables&gt;
                  &lt;action type="Redirect" url="https://www.website.com/{R:1}" appendQueryString="false" /&gt;
              &lt;/rule&gt;
              &lt;rule name="Add HTTPS to WWW.website.COM" stopProcessing="true"&gt;
                  &lt;match url="(.*)" /&gt;
                  &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="false"&gt;
                      &lt;add input="{HTTPS}" pattern="^OFF$" /&gt;
                      &lt;add input="{HTTP_HOST}" pattern="^www\.(.+)$" /&gt;
                  &lt;/conditions&gt;
                  &lt;serverVariables&gt;
                  &lt;/serverVariables&gt;
                  &lt;action type="Redirect" url="https://www.website.com/{R:1}" /&gt;
              &lt;/rule&gt;
          &lt;/system.webServer-rewrite-globalRules&gt;
      &lt;/CONFIG&gt;
  &lt;/appcmd&gt;
  </code></pre>
  
  <p>In above first rule Mobile redirect is done when user come from mobile browser. I redirect to <code>https://www.website.com/en-mobile</code> but when I do like this <code>https://m.website.com/en-mobile</code> it gives error but when I browse manually it works very good. So how can I redirect to that url when people come from <a href="https://www.website.com" rel="nofollow">https://www.website.com</a> to <a href="https://m.website.com/en-mobile" rel="nofollow">https://m.website.com/en-mobile</a></p>