Redirect folder to another with htaccess

Kamil

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?

anubhava

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related