重定向301无法正常运行

时间:2016-02-26 21:49:55

标签: .htaccess redirect

我正试图像这样执行301重定向:

<ifmodule mod_rewrite.c>

RewriteEngine On

##This is the redirect
RewriteRule /page/old-url http://website.com/page/new-url [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

</ifmodule>

但我有一个这样的网址:

http://website.com/page/new-url?route=page/old-url

我尝试过多种变体:

RedirectMatch 301 /page/old-url http://website.com/page/new-url

但仍然无法解决它

提前致谢!

1 个答案:

答案 0 :(得分:0)

有这样的话:

RewriteEngine On

##This is the redirect
RewriteRule ^page/old-url/?$ /page/new-url/ [R=301,L,NC]

RewriteCond %{REQUEST_FILENAME} !-f   
RewriteCond %{REQUEST_FILENAME} !-d    
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

确保在测试此更改之前清除浏览器缓存。