IIS http redirection to HTTPS

Source: Internet
Author: User

A recent customer site upgrade to HTTPS protocol access, but for user input, customer requirements when the user entered the HTTP protocol, can be automatically directed to HTTPS, similar to Baidu site, when you enter www.baidu.com and return, the address bar automatically became https://www.baidu.com.


The previous steps briefly describe how to implement this feature.

1 Download and install the Microsoft URL Rewrite module

https://www.microsoft.com/zh-CN/download/details.aspx?id=7435

Remark: According to different system, different language choice.

My machine is English version, so the following screenshots are basically English.

2 Site Binding of the following two protocols:


Note: The default HTTPS port number is 443, because my native port is already exploited, so this is a 449 demo.

3 The SSL settings of the site to ensure that "Require SSL" is not selected.


3 If it is a asp.net site, add the following configuration section directly in the Web.config file, as the child element of <configuration> at the end of the file.

<system.webServer>
<rewrite>
<rules>
<rule name= "Redirect to HTTPS" stopprocessing= "true" >
<match url= "(. *)"/>
<conditions>
<add input= "{HTTPS}" pattern= "^off$"/>
<add input= "{https_host}" pattern= "^ (localhost)" negate= "true"/>
</conditions>
<action type= "Redirect" url= "Https://{http_host}:449/{r:1}"Redirecttype=" Seeother "/>
</rule>
</rules>
</rewrite>
</system.webServer>

Note: When you use the default HTTPS port, the above port number 449 is not required, directly for https://{http_host}/{r:1}

The above configuration can also be manually added directly in the URL write in IIS, which is done roughly as follows:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.