[英]URL Rewrite Remove WWW From HTTPS
我需要在IIS8上的URL Rewrite中设置一条规则,以从所有https请求中删除www。
以下是我想要实现的目标。 如果我们从所有网址中删除www,我不在乎。
http://sitename.com/sub -> http://sitename.com/sub
http://www.sitename.com/sub -> http://www.sitename.com/sub
https://sitename.com/sub -> https://sitename.com/sub
https://www.sitename.com/sub -> https://sitename.com/sub
我得到它与这个规则一起工作。
<rule name="Remove WWW" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(sitename\.com)" />
</conditions>
<action type="Redirect" url="https://{C:2}/{R:1}" />
</rule>
我还在其上面添加了此规则以强制所有请求https
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.