【发布时间】:2012-11-28 11:37:30
【问题描述】:
网站使用 opencart cms,启用了 SEO url,所以 .htaccess 看起来:
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
一切都很完美,但我想添加从非 www 到 www 的 301 重定向,所以我添加了:
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
它有效,但是当我尝试使用类别或产品重定向链接时,它会添加“index.php?route="
例子:
“www.example.com/cats”,如果我尝试不带“www”的“example.com/cats”,链接将看起来 www.example.com/index.php?route=猫
【问题讨论】:
标签: .htaccess url-rewriting opencart