首页 > Web开发 > 详细

如何在 IIS 中重定向 http 请求至 https

时间:2021-05-10 23:04:56      阅读:26      评论:0      收藏:0      [点我收藏+]

曾经简单记录过一次:https://www.cnblogs.com/xwgli/p/12341961.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>

3、或者也可以手动在 IIS 中的图形界面进行配置,具体可以将上述配置放入 web.config 中后,转至 IIS 相应站点的“URL 重写”模块中查看

技术分享图片

4、好像配置完成就生效了,可以去浏览器中试试效果了~

参考:https://cloud.tencent.com/developer/article/1590146

https://www.cnblogs.com/wer-ltm/p/10190535.html

如何在 IIS 中重定向 http 请求至 https

原文:https://www.cnblogs.com/xwgli/p/14752403.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!