在我的.htaccess:
我尝试使用下面的代码将404页 about_us 页面重定向到 about-us 页面
redirect 301 /about_us http://www.example.com/about-us
但是当我尝试加载到浏览器以获取about-us页面时,重定向到此页面
http://www.example.com/about-us?_route_=about_us
但页面仍然是404错误
这是我的.htaccess规则
RewriteBase /
#RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
#RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [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]
答案 0 :(得分:3)
不要将redirect
规则与mod_rewrite
规则一起使用。这样做:
RewriteEngine On
RewriteBase /
RewriteRule ^about_us/?$ http://www.example.com/about-us [L,NC,R=301]
#RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
#RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [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]
确保在新浏览器中进行测试以避免旧的浏览器缓存。