Mark Henry
Mark Henry

Reputation: 2699

htaccess rewrite directory

I moved my website from the /v1/etc... directory to the /v2/etc... directory and would like to make a permanent redirect in htaccess. Can someone help me?

Upvotes: 4

Views: 8264

Answers (3)

dweeves
dweeves

Reputation: 5605

Put this:

RewriteEngine On
RewriteRule /v1/(.\*) /v2/(.\*) [R=301,L]

in your .htaccess file.

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798606

RedirectMatch permanent /v1/(.*) /v2/$1

Upvotes: 0

Gumbo
Gumbo

Reputation: 655229

You can use either mod_rewrite:

RewriteEngine on
RewriteRule ^v1(/.*)?$ /v2$1 [L,R=301]

Or mod_alias:

Redirect permanent /v1 /v2

Upvotes: 7

Related Questions