在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屋!