1
Reply

Automatically redirect http to https in IIS.

Ritesh Singh

Ritesh Singh

8y
1.9k
0
Reply

    IIS doesn’t have a feature to redirect HTTP to https. One way to achieve this is by modifying IIS custom error page (403.4). 1. a. Create a file called SSLRedirect.asp in your webroot with the following content:<% Data = request.servervariables(”QUERY_STRING”) URL = replace(Data, “403;”, “”) URL = replace(URL, “http://”, “https://”) response.Status = “200 OK” response.redirect URL %> Or if you want to redirect it to a single URL, you can change those lines above with this instead <% Response.Redirect(”https://www.YourDomain.com/”) %>b. Or Create a HTML SSLRedirect.html file as shown below : New Page 1 2. Open the IIS MMC tool, select properties for your site, go to the directory security tab, click the edit button at the bottom in secure communications, and then check “Require secure channel (SSL)” option. 3. In the IIS MMC tool under your site’s properties, go to the custom errors tab, select the 403;4 error type, edit its properties to be a URL in your site and change it to /SSLRedirect.asp OR /SSLRedirect.html4. Still in the IIS MMC tool, select the properties for the custom error file you have created previously (SSLRedirect.asp), go to the file security tab, click the edit button at the bottom in secure communications, and then UN-check “Require secure channel (SSL)” option.Now the visitor will be automatically redirected to HTTPS whenever they access the HTTP.