Forcing HTTPS on IIS

If you have an SSL certificate on your web site and it is hosted by IIS then you may wish to force the use of https on all pages.  This can be accomplished by adding a rewrite rule to the web.config file.  An example web.config file is provided below.  You should replace "www.yourdomain.com" with your domain name.  

<?xml version="1.0" encoding="UTF-8"?>

<configuration> 

  <system.webServer>

      <rewrite>

        <rules>

          <rule name="Redirect to HTTPS" stopProcessing="false">

            <match url="(.*)" />

            <conditions>

              <add input="{HTTPS}" pattern="^OFF$" />

            </conditions>

            <action type="Redirect" url="https://www.yourdomain.com/{R:1}" />

          </rule>

        </rules>

      </rewrite>   

  </system.webServer>

</configuration>

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Purchasing an SSL Certificate

***You must have a dedicated IP to install a certificate on your site***1. Sign In to our...

Generating a CSR on Linux

If you are purchasing an SSL certificate from CeraNet (Order Online) then we offer easy to use...