我正在尝试将所有网址重定向到https。
<rewrite>
<rules>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
但是,访问http://www.example.com并非重定向。我想要http://www.example.com
重定向到https://www.example.com
看来我的规则没有效果。条件可能错了吗?
答案 0 :(得分:0)
以下是一个示例:更多关注Rewrite URLs on an HTTPS page to HTTP
<rule name="ForceHttpToHttps" preCondition="ResponseIsHtml1">
<match filterByTags="A, Img" pattern="^(?!.*javascript).*$" />
<conditions>
<add input="{HTTP}" pattern="ON" />
<add input="{SERVER_PORT}" pattern="443" />
</conditions>
<action type="Rewrite" value="https://{HTTP_HOST}:1860{R:0}" />
</rule>