【发布时间】:2017-11-01 11:14:30
【问题描述】:
我的 webconfig 中的 HTTPS 重定向配置有问题:
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.be$" negate="true" />
<add input="{HTTPS}" pattern="OFF" ignoreCase="true" />
</conditions>
<action type="Redirect" url="http://www.domain.be/{R:1}" />
</rule>
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^domain\.be$" />
</conditions>
<action type="Redirect" url="https://www.domain.be/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
以下代码适用于:
- https://www.domain.be
- domain.be
- https://domain.be
但不适用于:
- www.domain.be
当我访问该 URL 时,总是会收到无限重定向错误。
谁能指出我在 web.config 中的错误?
提前致谢
【问题讨论】:
-
您可能需要查看docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/…,它解释了如何在 IIS 中测试重写规则。我还可以看到一个不一致之处;你说重定向到 HTTPS,但重定向到 HTTP。