URL重写从HTTPS中删除WWW [英] URL Rewrite Remove WWW From HTTPS
本文介绍了URL重写从HTTPS中删除WWW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在IIS8上的URL Rewrite中设置规则,以从所有https请求中删除www。
I need to set up a rule in URL Rewrite on IIS8 to remove the www from all https requests.
以下是我想要实现的目标。如果我们从所有网址中删除www,我都不在乎。
Below is what I want to achieve. I do not care if we remove www from all urls.
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
推荐答案
我得到了它适用于此规则。
I got it to work with this rule.
<rule name="Remove WWW" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(ccsportal\.com)" />
</conditions>
<action type="Redirect" url="https://{C:2}/{R:1}" />
</rule>
我还在其上方添加了此规则以强制所有请求https
I also added this rule above it to force all requests to 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="Found" />
</rule>
这篇关于URL重写从HTTPS中删除WWW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文