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: