IIS 7.5 上的 URL 重写问题
我正在尝试使用 IIS 7.5 的 URL 重写模块将我的 ASP.NET 网站的所有 HTTP 请求重定向到 HTTPS。该网站目前运行良好,但强制用户在地址栏中输入 https://。
我按照本文中的说明进行操作。一切似乎都很好:我尝试将规则放入 web.config 中,它会按预期显示在 UI 中;我也做了相反的操作,当我使用 UI 添加规则时,可以看到 web.config 中的更改。我未选中该网站的 RequireSSL。不幸的是,当我尝试通过 http:// 访问该网站时,我仍然收到 404 错误。
我尝试了几种不同的操作网址,包括 {HTTP_HOST}/{R:1} 和下面显示的网址..没有任何效果。
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}"
redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
我对此还很陌生,目前非常沮丧。看来这应该容易很多。任何建议将不胜感激,谢谢。
从 ServerFault 重新发布,因为它已经有一段时间没有得到答复了。
I'm trying to use the URL Rewrite module for IIS 7.5 to redirect all HTTP requests to HTTPS for my ASP.NET website. The site works fine at the moment but forces the user to type the https:// in the address bar.
I followed the instructions in this article. Everything seems to be fine: I've tried putting the rule in the web.config and it shows up in the UI as it should; I've also done the reverse and can see the changes in the web.config when I use the UI to add the rule. I have RequireSSL unchecked for the site. Unfortunately I still just get a 404 when I try to hit the site via http://.
I've tried a few different action urls including {HTTP_HOST}/{R:1} and the one shown below.. nothing works.
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}"
redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
I'm fairly new to this and pretty frustrated at this point. Seems like this should be a lot easier. Any advice would be appreciated, thanks..
Reposting from ServerFault as it's been sitting unanswered for a while.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您实际上有 HTTP 80 端口的绑定吗?听起来你没有它(只有 HTTPS)。
我问的原因是引用的文本是确切的消息,如果我请求未知的 IIS 域(当没有定义包罗万象时)或域未绑定到请求的域,我会看到该消息港口。
Do you actually have binding for HTTP 80 port? Sounds like you do not have it (only HTTPS).
The reason I'm asking is the quoted text is the exact message that I would see if I request unknown to IIS domain (when there is no catch-all defined) or domain is not bound to the requested port.