1.注意首先要安装url重定向模块
微软官方地址:https://www.microsoft.com/zh-CN/download/details.aspx?id=7435
百度网盘地址:链接: https://pan.baidu.com/s/1N4yISzmYCcY_c-uYWQ3ojA 密码: 4pse
2.web.config配置文件新增
<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}/{R:1}" redirectType="SeeOther" /> </rule> </rules> </rewrite> </system.webServer>