Mod 重写 https 问题,从 url 中去除 www
我们有一个例如 https://www.egdomain.com/
的 url,并且 ssl 对egdomain.com 有效。 那么我怎样才能将所有请求从 https://www.egdomain.com/
重定向到 https://egdomain.com/
该网站也有正常的 http 请求工作正常。
我尝试了下面的 htaccess 但仍然没有
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteCond %{HTTP_PORT} =443
RewriteRule (.*) https://%1/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule (.*) http://%1/$1 [L,R=301]
任何帮助,我们将不胜感激
we have a url for eg https://www.egdomain.com/
and the ssl is valid for egdomain.com.
so how can i redirect all the requests from https://www.egdomain.com/
to https://egdomain.com/
the site also has normal http requests which works fine.
I tried the htaccess below but still nothing
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteCond %{HTTP_PORT} =443
RewriteRule (.*) https://%1/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule (.*) http://%1/$1 [L,R=301]
Any help will e much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将这两个规则合并为一个:
但这可能有点太混乱了。
You can combine these two rules to one:
But maybe this is a little too confusing.
手册说(强调我的):
因此:
请注意,如果您的证书仅对不带
www.
的变体有效,访问者在访问www.
变体时仍会收到安全警告。The manual says (emphasis mine):
So:
Note that if your certificate is only valid for the variant without
www.
, visitors will still get a security warning when accessing thewww.
variant.