htaccess 将 www 重定向到非 www 而不更改地址
htaccess redirect www to non-www without changing in address
我有这个地址
http://name.com/category/1/news
我在 htaccess 中使用这段代码强制打开没有 www 的页面。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
当我打开 http://www.name.com/category/1/news
然后我重定向到
http://name.com/category.php?id=1&slug=news
这是我的完整 htaccess 文件。
RewriteEngine on
RewriteRule ^news/(.*)$ news.php?id=&slug=
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
谢谢。
尝试:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [NE,R=301,L]
RewriteRule ^news/(.*)$ news.php?id=&slug= [NC,L]
我有这个地址
http://name.com/category/1/news
我在 htaccess 中使用这段代码强制打开没有 www 的页面。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
当我打开 http://www.name.com/category/1/news
然后我重定向到
http://name.com/category.php?id=1&slug=news
这是我的完整 htaccess 文件。
RewriteEngine on
RewriteRule ^news/(.*)$ news.php?id=&slug=
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
谢谢。
尝试:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [NE,R=301,L]
RewriteRule ^news/(.*)$ news.php?id=&slug= [NC,L]