更新时间:2022-04-11 06:05:25
我认为这对您有用,搜索模式有可选的www和重定向使用后向引用C:2,规则有条件只对非https运行。
I think this will work for you, the search pattern has the optional www and redirects using the back reference C:2, the rule has a condition to only run against non https.
这是模式:
"^(www\.)?(.*)$"
其中:
{C:0} - www.domain.de
{C:1} - www.
{C:2} - domain.de
这是完整的规则:
<rewrite>
<rules>
<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>
</rules>
</rewrite>