title: HTTP to HTTPS Redirect in IIS
body: <p>I have to redirect my site from http to https, whenever any user open my site using http. </p>
  
  <p>For example: -</p>
  
  <p>http:\\abc.mywebsite.com  should go to https:\\abc.mywebsite.com</p>
  
  <p>Notice that in above URL, it is not www.mywebsite.com, instead it is custom URL as abc.mywebsite.com.</p>
  
  <p>I have tried <a href="https://www.iis.net/downloads/microsoft/url-rewrite" rel="nofollow noreferrer">URL Rewrite</a> tool and followed all steps mentioned <a href="https://www.namecheap.com/support/knowledgebase/article.aspx/9953/38/iis-redirect-http-to-https" rel="nofollow noreferrer">here</a>.  However, I cannot get URL Rewrite to work properly to redirect. </p>
  
  <p>Here is the URL Redirect rule looks like in IIS: -</p>
  
  <p><a href="https://i.stack.imgur.com/TfNR5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TfNR5.png" alt="enter image description here"></a></p>
  
  <p>Here is how my web.config looks like after adding rule using URL Rewrite.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;configuration&gt;
    .....
    .....
    .....
    &lt;system.webServer&gt;
      .....
      .....
      .....
      &lt;rewrite&gt;
        &lt;rules&gt;
          &lt;rule name="Http to Https" enabled="true" stopProcessing="true"&gt;
            &lt;match url="(.*)" /&gt;
             &lt;conditions logicalGrouping="MatchAny"&gt;
              &lt;add input="{HTTPS}" pattern="^OFF$" /&gt;
             &lt;/conditions&gt;
            &lt;action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" /&gt;
          &lt;/rule&gt;
        &lt;/rules&gt;
      &lt;/rewrite&gt;
    &lt;/system.webServer&gt;
    .....
    .....
    .....
  &lt;/configuration&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have also uncheck Require SSL check box under SSL Settings.</p>
  
  <p>However, after doing all this, my website is still not redirecting to https. Just giving error "...can't reach this page".</p>
  
  <p>Please suggest if I am missing anything here.</p>