我想强制所有http请求重定向到https,所以我现在有了这个规则:
<rules>
<clear />
<rule name="force https" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP}" pattern="on" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="(sitea\.com)|(sitea\.uk)|(sitea\.org)" negate="true" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
但是,当我请求示例http://www.sitea.com
时,它不会重定向到https://www.sitea.com
。
(在旁注:我也想知道这是否对SEO有任何负面影响)
答案 0 :(得分:1)
这就是我们使用的
<rule name="httpsredirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
我可以看到一些差异 - 我们有{R:1}你有{REQUEST_URI}我们只输入了一个关闭https的条件,所以只有http被重定向,这可能是你出错的地方。
至于搜索引擎优化 - 这是一个很大的主题 - 但是由于你正在进行永久重定向,搜索引擎会认识到并将网址从索引中删除,而是使用https。