
IIS 里 安装好 SSL 证书后,如何实现 在浏览器里录入 http://www.xxx.com,会自动跳转到 https://www.xxx.com 呢。
首先,下载并安装 IIS 扩展: URL重写(URL Rewrite)扩展
URL重写扩展下载地址: https://www.iis.net/downloads/microsoft/url-rewrite
其次,修改 web.config 文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
最后,重启网站 或重启 IIS。在浏览器里录入:http://www.xxx.com,会自动跳转到 https://www.xxx.com