URL Rewrite – Redirect http to https in IIS

URL Rewrite – Redirect http to https in IIS

Redirecting HTTP to HTTPS is the most common requirement we receive as a sysadmin. Below are the steps to perform the task.

  1. Make sure you’ve got the URL rewrite module installed in IIS. If you aren’t sure if you do or not, you’ll find out quickly when you can’t find “URL Rewrite” in the steps below. Here are downloads for the 32bit version or the 64bit version.
  2. After you install the URL Rewrite module, you can perform the task in two ways: IIS GUI and web.config XML. I prefer doing this through the web.config file, but the GUI will also be shown here.


To redirect http://mydomain.com -> https://mydomain.com

Using web.config XML:
Create, if it doesn’t exist already, a     section and copy & paste the following code. Be sure to replace mydomain with the hostname of your website.

<!-- Redirect to HTTPS -->
                <rule name="http to https" stopProcessing="true">
                    <match url="(.*)" />
                        <add input="{HTTPS}" pattern="^OFF$" />
                    <action type="Redirect" url="https://www.domain.com/{R:1}" redirectType="Permanent" />

Using IIS URL Rewrite GUI:
1. Select your website in IIS Manager and then click on the “URL Rewrite” option in the features pane.

2. Once URL Rewrite screen is open, click the “Add Rules…” link in the right hand pane and enter the details as shown below.
3. Select Blank Rule from the inbound rules section.
4. Give it a descriptive name.
5. Match URL section:

  • Set Requested URL to Matches the Pattern.
  • Set Using to Regular Expression
  • Set Pattern to (.*)

7. Next in the Conditions section. Click Add

  • Set Condition Input to {HTTPS}
  • Set Check if Input String to Matches the Pattern
  • Set Pattern to ^OFF$
  • Click OK

8. In the Actions section

  • Set Action Type to Redirect
  • Set Redirect URL to https://{HTTP_HOST}/{R:1}
  • Set Redirect Type to Permanent(301)
  • Click Apply

Now all request to that site should be redirected (301 permanent redirects) to the https version of the site.


Safi Ahmed Choudhury

Safi Ahmed Choudhury

Safi is the founder and chief editor of ZoomTutorials Blog, a leading tutorials and technology blogging site specializing in DevOps, SysAdmin and Cloud Technologies to help IT professionals in their day to day work. He is a Senior Cloud and DevOps Solutions Engineer at a leading eCommerce development Company and has more than 8 years of SysAdmin experience working with Fortune 500 companies to solve their most important IT backbones. Safi lives in Hyderabad with his wife and a son.

Leave a Reply

Your email address will not be published. Required fields are marked *