[英]Force https redirect on all http requests on IIS
我想强制所有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有负面影响)
这就是我们使用的
<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被重定向了,这也许就是您出问题的地方。
至于SEO-这是一个很大的主题-但由于您正在执行永久重定向,因此搜索引擎将识别出该URL并将网址从其索引中删除,而改用https。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.