简体   繁体   中英

Redirect 301 doesn't work properly

I'm trying to perfom a 301 redirect like this:

<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>

But I got a url like this:

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

I tried many variations for instance:

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

But still can't fix it

Thanks in advance!

Have it like this:

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]

Make sure to clear your browser cache before testing this change.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM