在 IIS7 中将 URL 从 https:// 重写为 http://
我正在尝试
https://example.com/about
将 URL 从表单重写为表单
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 trying to rewrite urls from the form:
https://example.com/about
to the form
http://example.com/about
using IIS7 URL rewriting:
<!-- 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>
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
事实证明,我将端口 :443 绑定到了另一个网站!
上述重写规则适用于 http:// 到 https:// 重写,反之亦然 - 尽管可能有更优化的方案或简单的方法来做到这一点。
把这个问题留在这里让以后的航海者去寻找,因为我在网上没有看到很多 https:// 到 http:// 重写场景的好例子。
Turns out that I had port :443 bound to a different website!
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.
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.
这篇文章有点老了,但我想回答一下。我正在使用 ASP.Net MVC3,Fabio 的上述答案对我不起作用。我想出的最简单的解决方案来处理 https 重定向到 http,同时仍然允许有效的 https 页面请求安全内容,只是在 https/http 重定向上方添加白名单规则:
This post is a little old, but I wanted to answer. I am using ASP.Net MVC3, and Fabio's answer above didn't work for me. The easiest solution I came up with to handle the https redirect to http, while still allowing valid https pages to request secure content was just to add Whitelist rules above my https/http redirects:
请首先考虑绑定 https到您的网站,以使下面的重定向模块正常工作是必不可少的(因此将您的网络应用程序与自签名或有效 证书)
web.config 中的最后一部分将 https 重定向到 http:
如果您需要重写模块中的等效 IIS GUI,请参见下图
来源:查看 tech-net 了解更多详细信息和分步指南。
please first consider binding https to your website for making below redirect module to work is essential (so bind your web app with a self-signed or valid certificate)
final part in web.config to redirect https to http:
if you need the equivalent IIS GUI in rewrite module see below image
source: look tech-net for more detail and step by step guide.
您的解决方案有效,但问题是:您的第二条指令杀死任何链接的第一条指令不是 (.)billing/(.),包括您的 css、js 和图像。
您可以使用此 https 到 http 规则:
Your solution work, but the problem is: your second instruction kill first instruction for any links is not (.)billing/(.), including your css, js, and images.
You can use this https to http rule: