title: IIS 7.5 HTTP to HTTPS redirect
body: <p>I am trying to have all HTTP requests redirect to HTTPS.
  Here is my web.config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;system.webServer&gt;
          &lt;handlers accessPolicy="Read, Execute, Script" /&gt;
      &lt;/system.webServer&gt;
  
  
      &lt;system.webServer&gt;
         &lt;rewrite&gt;
              &lt;rules&gt;
                  &lt;clear /&gt;
                  &lt;rule name="Redirect to https" stopProcessing="true"&gt;
                      &lt;match url="(.*)" /&gt;
                      &lt;conditions&gt;
                          &lt;add input="{HTTPS}" pattern="off" ignoreCase="true" /&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>
  
  <p>I found this sample in another post on Stackoverflow:
  <a href="https://stackoverflow.com/questions/9823010/how-to-force-https-using-a-web-config-file">How to force HTTPS using a web.config file</a></p>
  
  <p>When I save that file and try to access my site using http it does not redirect to https.</p>
  
  <p>I thought that maybe the file was being ignored so I typed some incorrect syntax into the web.config then I got a 500 error- meaning that it is indeed looking at the web.config file.</p>
  
  <p>Am I misunderstanding what the above configuration is supposed to do?  I want to redirect all HTTP request to HTTPS.</p>
  
  <p>The site that is being redirected to is a virtual directory for Tomcat if it makes a difference.</p>