【发布时间】:2018-07-05 12:24:56
【问题描述】:
页面应该使用 301 重定向从 http://example.com/... 重定向到 https://www.example.com/...。
页面应该使用 301 重定向从 http://www.example.com/... 重定向到 https://www.example.com/...。
页面应该使用 301 重定向从 https://example.com/... 重定向到 https://www.example.com/...。
我在 web.config 中添加了以下 URL 重写。
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:0}" />
</rule>
<rule name="Redirect example.com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.com" />
<add input="{HTTPS}" pattern="on" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" redirectType="Permanent"/>
</rule>
上面的代码不能正常工作。
- 当我们输入https://example.com 时,它不会重定向到https://www.example.com
【问题讨论】:
-
您可能希望在第二条规则的 HTTPS 条件上使用
ignoreCase属性。
标签: asp.net iis web-config sitecore