我有这个地址
http://name.com/category/1/news
我在htaccess中使用此代码强制打开没有www的页面。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$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=$1&slug=$2
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
感谢。
答案 0 :(得分:0)
尝试:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [NE,R=301,L]
RewriteRule ^news/(.*)$ news.php?id=$1&slug=$2 [NC,L]