此文章发布于71
个月前,部分信息可能已经过时
,请自行斟酌确认。
业务场景
公司 APP 及扫描枪的服务端目前搭建在网站(http://xxx.xxx.cn),为了网络传输安全性目前网站已经采用 https
协议进行安全传输,使用 Chrome 浏览器的同事应该发现了,访问 http 的地址时在地址栏前面会显示不安全
字样。但扫描枪目前使用的 WinCE 系统通过程序访问 https 地址时有些问题没有解决,所以暂时只能访问 http 的地址。
目的
让除扫描枪接口以外所有应用均通过 https 安全连接,效果是:除扫描枪使用的 wince.asmx 地址以外所有地址都自动跳转到 https 地址。
配置方法
- IIS服务器安装URL重写工具
- 添加以下规则
<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>