IIS 配置 http 自动跳转 https 并排除指定的 URL

此文章发布于 71 个月前,部分信息可能已经过时,请自行斟酌确认。

业务场景

公司 APP 及扫描枪的服务端目前搭建在网站(http://xxx.xxx.cn),为了网络传输安全性目前网站已经采用 https 协议进行安全传输,使用 Chrome 浏览器的同事应该发现了,访问 http 的地址时在地址栏前面会显示不安全字样。但扫描枪目前使用的 WinCE 系统通过程序访问 https 地址时有些问题没有解决,所以暂时只能访问 http 的地址。

目的

让除扫描枪接口以外所有应用均通过 https 安全连接,效果是:除扫描枪使用的 wince.asmx 地址以外所有地址都自动跳转到 https 地址。

配置方法

  1. IIS服务器安装URL重写工具
  2. 添加以下规则
<system.webServer>
<rewrite>
    <rules>
        <rule name="httptohttps-no-wince.asmx" stopProcessing="true">
            <match url="^(.*)" />
            <conditions>
                <add input="{URL}" pattern="^.*wince.asmx.*$" negate="true" />
                <add input="{HTTPS}" pattern="^OFF$" />
            </conditions>
            <action type="Redirect" url="https://weiku.co/{R:1}" redirectType="Found" />
        </rule>
    </rules>
</rewrite>
</system.webServer>

8_2_26003afa61ea141.png

20190420085209754.png

最后修改:2019 年 04 月 20 日 08 : 54 AM
如果觉得我的文章对你有用,请随意赞赏

发表评论