Recently customer a website upgrade to HTTPS protocol access, but for user input, customer requirements when the user entered the HTTP protocol, can automatically direct to HTTPS, similar to Baidu website, when you enter www.baidu.com and enter, the address bar automatically become 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
Note: Depending on the system, different languages are selected.
My machine is in English, so the following basic is English.
2) The site binds to the following two types of protocols:
Note: The default HTTPS port number is 443 because my native port has been exploited, so this is a 449 demo.
3) The SSL setting of the site, make sure "Require SSL" is not selected.
3) In the case of an ASP. NET site, add the following configuration section directly in the Web. config file, and place it as a child 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 to 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:
IIS http redirection to HTTPS