目前,我的规则是:
<rule name="SecureRedirect" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}" redirectType="Permanent" />
</rule>
问题在于:
http://www.domainName.com/image.png
错误地重定向到https://domainName.com
而不是https://domainName.com/image.png
和
https://www.domainName.com/image.png
无法重定向到https://domainName.com/image.png
那么,将所有内容重定向到非www https网址的真正方法是什么?
答案 0 :(得分:1)
符合您所有要求的正确规则是:
<rule name="SecureRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{C:2}/{R:1}" redirectType="Permanent" />
</rule>
答案 1 :(得分:0)
我在网站上的方式如下:
ServerName www.example.com
ServerAlias example.com
Redirect / https://www.example.com/
答案 2 :(得分:0)
尝试此规则:
<rule name="SecureRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>