How to Redirect HTTP to HTTPS with IIS 7

Download PDF

In IIS, to redirect (force) HTTPS on every HTTP request, do the following.

Before you start, make sure you have the following done;

  • IIS 7 installed
  • Microsoft URL Rewrite Module installed
  • Create HTTPS bindings to your IIS website and assign certificate
  • Ensure Require SSL is NOT checked under SSL Settings for your website

Once you have this done you can simply copy and paste the following code between the <rules>and </rules> tags in your your web.config file in your website root directory.

Please note if you already have some rules in you web.config file, make sure to put the bellow rule within <rules>. Every rule ends with <rule> and then all rules end with <ruleS>, so make sure not to put this rule inside another rule.

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />

Now save the web.config file and it’s all done.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply