IIS7/IIS8/的HTTP到HTTPS的重定向 |
一、配置web.config文件 1.找到网站根目录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> 2.重启IIS测试访问。 |