【发布时间】:2013-12-03 07:06:40
【问题描述】:
我的问题正是here 提出的问题,我决定尝试将所有https 请求重写为http。我已经进行了漫长而艰苦的搜索,但似乎没有明确的方法来实现这一目标 - 请参阅这些问题(无解决方案):Redirect https to http using rewrite rule in webconfig file; https://stackoverflow.com/questions/15214717/iis-rewrite-https-to-http-whilst-keeping-existing-https-rules
我已将重写模块添加到 IIS,并在 web.config 中尝试了以下操作:
<rewrite>
<rules>
<clear />
<rule name="force http" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
但它仍然允许用户使用 https 访问非 https 站点(本质上是访问不同的站点)。
如何强制所有 https 请求为 http 请求?
编辑:我也尝试了所有建议的解决方案here,但没有成功。 url rewrite模块在IIS上肯定安装成功了!
edit2:尝试了以下但没有成功:
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="force http" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="^(?:www)?\.test.site\.com$"
negate="true" ignoreCase="true" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
我重新启动了 IIS,重写规则反映在 inetmgr 中。加载 https://test.site.com/ 时仍会加载 https。
【问题讨论】:
-
您是否可以选择向服务器添加额外的 IP 地址以便更改绑定?
-
有那个选项,但我想让 URL 重写按预期工作
-
询问 IP 地址,因为似乎 URL 重写模块旨在仅在将请求分配给 IIS 站点后处理处理,因为匹配 URL 在主机之后开始。我认为IP地址最好,但没有它也可以完成。请参阅下面的答案。
标签: asp.net http iis https url-rewrite-module