如何总是从一个mod_rewrite的URL删除WWW? [英] How to always remove WWW from a url with mod_rewrite?
本文介绍了如何总是从一个mod_rewrite的URL删除WWW?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面尝试从URL中移除WWW:
I'm using the following to try and remove WWW from the url:
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule (.*) http://example.com$1 [R=301]
但出于某种原因,这是行不通的。有什么建议?
But for some reason it doesn't work. Any suggestions?
推荐答案
尝试:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
和无的mod_rewrite
:
<VirtualHost 10.0.0.1:80>
ServerName www.example.com
Redirect permanent / http://example.com/
</VirtualHost>
虚拟主机可以通过完成以下URL的步骤中使用:设置Apache中虚拟主机
这篇关于如何总是从一个mod_rewrite的URL删除WWW?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文