IIS HTTPS无限重定向
问题描述:
我有一个问题,我的HTTPS在我的webconfig重定向配置:IIS 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中指出我的错误吗?
在此先感谢
答
这个规则可以被用来发送一切不是HTTPS,不www.domain.be到https://www.domain.be/
<rewrite>
<rules>
<rule name="redirect to https www" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^www\.domain\.be$" negate="true" />
<add input="{HTTPS}" pattern="ON" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" url="https://www.domain.be/{R:0}" />
</rule>
</rules>
</rewrite>
您可能要检查https://开头的文档.microsoft.com/en-us/iis/extensions/url-rewrite-module/testing-rewrite-rule-patterns解释了如何在IIS中测试重写规则。我还可以看到一个不一致的地方;你说重定向到HTTPS,但重定向转到HTTP。 – Cebe