Force SSL in IIS7 (via URL Rewrite Module)

In order for this to work you’ll need to install the URL Rewrite module on your machine first.

Just know that after installing the module on your machine might force you to restart IIS and/or the machine itself.

Add the following to your web.config:

<system.webServer>

 

  <rewrite>

    <rules>

      <clear />

      <rule name=Redirect to https stopProcessing=true>

        <match url=(.*) />

        <conditions>

          <add input={HTTPS} pattern=off ignoreCase=true />

        </conditions>

        <action type=Redirect url=https://{HTTP_HOST}{REQUEST_URI} redirectType=Permanent />

      </rule>

    </rules>

  </rewrite>

 

</system.webServer>

 

Leave a Reply