在 IIS7 中将 URL 从 https://重写为 http:// [英] Rewriting URLs from https:// to http:// in IIS7
问题描述
我正在尝试从表单中重写网址:
I'm trying to rewrite urls from the form:
https://example.com/about
表格
http://example.com/about
使用IIS7 URL重写:
<!-- http:// to https:// rule -->
<rule name="ForceHttpsBilling" stopProcessing="true">
<match url="(.*)billing/(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="false" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
<!-- https:// to http:// rule -->
<rule name="ForceNonHttps" stopProcessing="true">
<match url="(.*)billing/(.*)" ignoreCase="true" negate="true" />
<conditions>
<add input="{SERVER_PORT}" pattern="^443$" />
</conditions>
<action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}{REQUEST_URI}" />
</rule>
我不知所措;我一直在网上浏览示例并尝试我能想到的每一种语法.我指定的重写规则对于任何 https 请求似乎根本不起作用,就好像所有 https://
请求对重写引擎完全不可见.
I'm at a loss; I've been browsing the web for examples and trying every syntax I can think of. The rewrite rules I specify simply don't appear to work at all for any https requests, as if all the https://
requests are flat out invisible to the rewrite engine.
规则工作正常;请参阅下面的答案.
rules work fine; see answer below.
推荐答案
结果是我将端口 :443 绑定到了不同的网站!
上述重写规则适用于 http://到 https://的重写,反之亦然——尽管可能有更优化或更简单的方法来做到这一点.
The above rewrite rules work fine for http:// to https:// rewriting and vice-versa -- though there might be more optimal or simple ways to do it.
把这个问题留在这里让未来的航海者去寻找,因为我在网上没有看到很多关于 https://到 http://重写场景的好例子.
Leaving this question here for future voyagers to find, as I didn't see many good examples of the https:// to http:// rewriting scenario on the web.
这篇关于在 IIS7 中将 URL 从 https://重写为 http://的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!