I've got a problem with redirecting folder to a new one. I don't want to use php header() or something similar, i want to achieve this effect with mod_rewrite module and .htaccess file.
The thing I'm trying to do is to redirect the http://domain.com/test/ address to http://domain.com/new/. It's not rewriting, it has to just move the user from old to new address. I was trying to use:
RewriteRule ^test/(.*) new/$1
But it throws 404 error cause catalog test does not exists. How can i redirect the user without creating another folder?
You can use external redirect:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^test/(.*)$ /new/$1 [L,NC,R=302]
If you don't want external redirect (no change of URL in browser) then remove R
flag:
RewriteRule ^test/(.*)$ /new/$1 [L,NC]
PS: Please elaborate: It's not rewriting, it has to just move the user from old to new address
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With