IIS: Redirect from http to https

I have faced a different troubles when was trying to make redirect from http to http url. Sitecore and IIS have a huge capabilities that some of them are a bit conflicting with each other. Indeed, I have tried to get it work and installed URL Rewrite module for IIS, and it worked like charm for the time being until I began sitecore upgrade and switched pipeline mode from “Classic” to “Integrated”, and fun began. Btw. I used this article for settings of redirection.

So, I’m going to show you one of the ways how to make URL redirect from http to https. Of course, I do not say that it’s the most perfect way to get redirect work, this is not a guide to action, it’s just one way how you can make it.

This is, of course, relates to all ASP.NET websites, not only with Sitecore one.

Step 1

Let’s create two websites: my_amazing_site_redirect.com and my_amazing_site.com. The idea is if a user will go to your website by http, he get  my_amazing_site_redirect and immediately redirect to the https://my_amazing_site.

Step 2

Let’s setting up two created websites. Open Features View window for my_amazing_site_redirect site and click by Bindings…

IIS 7 - Features View

Make sure that type is http

Site Bindings

In the Features View window for my_amazing_site_redirect click by HTTP Redirect

IIS 7 - Features View


And you will see next window, you have to make all changes as it is on the figure

IIS 7 HTTP Redirect


Pay attention on the suffixes at the end of url address

$S – Passes the suffix of the requested URL to the new URL. The suffix is the portion of the original URL that remains after the redirected URL is substituted.

If the EXACT_DESTINATION flag is not set, the resulting destination URL will have the name of the requested file appended as a folder name, as well as the file name itself.

$Q – Passes parameters (such as query string parameters) in the original URL to the new URL, including the question mark (?).

more details about suffixes you can find here

Step 3

Click Bindings… for my_amazing_site and make sure that type is https

Site Bindings


Step 4

Add web.config with next strings to folder where redirect website is located

<?xml version="1.0" encoding="UTF-8"?>
        <httpRedirect enabled="true" destination="https://my_amazing_site.com$S$Q" exactDestination="true" httpResponseStatus="Permanent" />

Have a good day to you!