title: HTTP to HTTPS Redirect - IIS 8.5 not working properly
body: <p>I've read a number of posts here on SO as well as on the 'net (IIS blogs, etc.). I'm trying to <strong>force all connections going from domain.com to www.domain.com and at the same time forcing the request from HTTP to HTTPS</strong>.</p>
  
  <p>I'm using this set of rules and rewrites but the only thing happening is that it's redirecting fine but not redirecting to SSL.</p>
  
  <pre><code>&lt;!-- Redirect to HTTPS --&gt;
  &lt;rewrite&gt;
      &lt;rules&gt;
          &lt;rule name="Redirect to www" stopProcessing="true"&gt;
              &lt;match url="(.*)" /&gt;
              &lt;conditions trackAllCaptures="false"&gt;
                  &lt;add input="{HTTP_HOST}" matchType="Pattern" pattern="^mydomain.com$" ignoreCase="true" negate="false" /&gt;
              &lt;/conditions&gt;
              &lt;action type="Redirect" url="{MapProtocol:{HTTPS}}://www.mydomain.com/{R:1}" /&gt;
          &lt;/rule&gt;
      &lt;/rules&gt;
      &lt;rewriteMaps&gt;
          &lt;rewriteMap name="MapProtocol" defaultValue="http"&gt;
            &lt;add key="on" value="https" /&gt;
            &lt;add key="off" value="http" /&gt;
          &lt;/rewriteMap&gt;
      &lt;/rewriteMaps&gt;
  &lt;/rewrite&gt;
  </code></pre>
  
  <p>What am I doing wrong? </p>
  
  <p>Main blog reference: <a href="http://weblogs.asp.net/owscott/url-rewrite-protocol-http-https-in-the-action" rel="noreferrer">http://weblogs.asp.net/owscott/url-rewrite-protocol-http-https-in-the-action</a> and this SO post - <a href="https://stackoverflow.com/questions/17714732/web-config-redirect-non-www-to-www">web.config redirect non-www to www</a></p>