通过url规则匹配重定向到新的url中,使用浏览器打开链接时,视觉上会看到http变成https,就好像打开http://www.chongfanmitu.com,链接会变成https://www.chongfanmitu.com
以下转自:https://www.cnblogs.com/xwgli/p/14752403.html
1、下载并安装 rewrite 模块,支持 IIS 7 及以上版本
https://www.iis.net/downloads/microsoft/url-rewrite
2、在站点的 web.config 文件中增加 rewrite 规则配置

<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="强制跳转 https 路径" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>