在网站设置中,“配置文件”配置添加如下代码:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" ></match> <conditions> <add input="{HTTPS}" pattern="^OFF$" ></add> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" ></action> </rule> </rules> </rewrite> </system.webServer> </configuration>