title: IIS Url rewrite - unsecured www to secured www
body: <p>My site is published on IIS 8 (V.10.0.17), and I have added rules for redirecting to https.</p>
  
  <p>All cases are covered:</p>
  
  <ol>
  <li><a href="https://example.com" rel="nofollow noreferrer">https://example.com</a>     -> <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></li>
  <li><a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a> -> <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></li>
  <li>www.example.com         -> <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></li>
  <li>example.com             -> <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></li>
  </ol>
  
  <p>except this one:</p>
  
  <ol start="5">
  <li><a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a> -> <strong>is not redirecting to</strong>: <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></li>
  </ol>
  
  <p>Not sure what am I missing, here is my web.confing:</p>
  
  <pre><code>&lt;system.webServer&gt;
          &lt;rewrite&gt;
              &lt;rules&gt;
                  &lt;rule name="CanonicalHostNameRule1"&gt;
                      &lt;match url="(.*)" /&gt;
                      &lt;conditions&gt;
                          &lt;add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" /&gt;
                      &lt;/conditions&gt;
                      &lt;action type="Redirect" url="http://example.com/{R:1}" /&gt;
                  &lt;/rule&gt;
                  &lt;rule name="HttpToHttps" stopProcessing="true"&gt;
                      &lt;match url="(.*)" /&gt;
                      &lt;conditions&gt;
                          &lt;add input="{HTTPS}" pattern="^OFF$" /&gt;
                      &lt;/conditions&gt;
                      &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" /&gt;
                  &lt;/rule&gt;
              &lt;/rules&gt;
          &lt;/rewrite&gt;
      &lt;/system.webServer&gt;
  </code></pre>