Get your FREE copy of "The Ultimate Guide of SSL"

Download Ebook

IIS Redirect HTTP to HTTPS : Enabling the HTTPS Redirection in IIS

Step-by-Step Instructions for using a URL Rewrite to Redirect HTTP to HTTPS in IIS

Before you can set out with an HTTP/HTTPS redirect in IIS, you’ll need to make sure that you have an SSL certificate already installed. This is not a step you can skip. Once you’ve got the certificate installed, we can start working on a URL rewrite to redirect your traffic to your new-fangled HTTPS site.

Steps for IIS Redirect HTTP to HTTPS

1. Download and install the IIS URL Rewrite Module

2. Open IIS Manager, in the console select the website you want to redirect

3. Select URL Rewrite

url-rewrite-iis
4. Click Add Rules

5.Select Blank Rule, click OK

add-rules-image
6. Enter the Name of rule

7. In the Match URL section choose “Matches the Pattern” in the Requested URL drop-down

8. Next select “Regular Expressions” in the Using drop-down

9. In the Match URL section enter: “(.*)

match-url-window-iis
10. In the conditions section, select Match All under Logical Grouping, the click Add
11. In the next window: 

  • Enter {HTTPS} as the condition input
  • Select “Matches and Pattern” from the drop-down
  • Enter ^OFF$ as the pattern
  • Click OK
iis-edit-condition-window
12. In the Action section, click Redirect and then specify the Redirect URL as: https://{HTTP_HOST}/{R:1}

13.Check the Append Query String box

14. Choose your redirection type (301)

iis-action-window
15. Click Apply

Next, you’ll have to apply the rule to your website.

Setting up IIS HTTP to HTTPS Redirect Rules

1. In the IIS dashboard, right click on your site and select Explore

iis-connections-window
2. Your Root Directory will open, select the web.config file and open it

3. Make sure the file contains the following code block (if not, add it)

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”HTTPS force” enabled=”true” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”^OFF$” />
</conditions>
<action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” redirectType=”Permanent” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

4. If you haven’t web.config file in your root directory, create new .txt file, just place the above code in it, save and then rename the file to web.config.

Note: These above steps to redirecting IIS from HTTP to HTTPS works with IIS 5, 6, 7, 8, 8.5, and IIS 10.

95%
OFF

comodo-square-logo

Comodo Positive SSL

$6.55

Vendor Price: $41.73

Coupon Code: ASCSCPSSL4

Get It Now

78%
OFF

rapidssl-coupon-square-logo

RapidSSL Certificate

$13.45

Vendor Price: $69

Coupon Code: ASRSRSSL2

Get It Now

95%
OFF

comodo-square-logo

Comodo PositiveSSL Multi-Domain

$17.54 – 2 SAN Included

Vendor Price: $41.73

Coupon Code: ASCSCPMD4

Get It Now

Important Articles:

Disclosure: AboutSSL appreciates your continuous support. It helps us tremendously to keep moving in the competitive SSL industry. Here most of the links which direct you to buy any SSL/TLS related service or products earns us a certain percentage of referral commission. Learn More