【发布时间】:2014-11-30 22:05:02
【问题描述】:
我正在尝试编写 URL 重写规则来强制建立 HTTPS 连接。这应该总是发生,除非请求使用 localhost(例如http://localhost/mysite)。
规则配置如下:
<rule name="Redirect to https" enabled="true" stopProcessing="true">
<match url="(.*)" negate="false" />
<conditions trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{URL}" pattern="localhost" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
我还尝试在没有帮助的情况下使用 ^localhost 和 ^localhost/(.*) 作为 URL 条件的模式。 有谁知道为什么这不起作用以及这个问题的解决方案应该是什么?
【问题讨论】:
-
哪个版本的 IIS?您可能想用它来更新您的问题。
-
现在我在 IIS8 上使用它。但是您已经提供了解决方案。非常感谢。