我想从我的网站域的所有url中删除www。我使用了以下代码
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
但是这段代码只将http://www.example.com
重定向到http://example.com
我希望http://www.example.com/abcd
也像http://example.com/abcd
一样
请帮帮我。非常感谢您的帮助。提前感谢。
您可以在root .htaccess中使用此规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(example.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
请确保在新浏览器中测试。
try this
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^/?$ "http://example.com/" [R=301,L]