Htaccess rewrite directory

I moved my website from the / v 1 / etc ... directory to the / v 2 / etc ... directory and would like to do a permanent redirect to htaccess. Can anybody help me?

+4
source share
3 answers

You can use mod_rewrite :

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

Or mod_alias :

 Redirect permanent /v1 /v2 
+7
source

Put this:

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

in your .htaccess file.

+1
source
 RedirectMatch permanent /v1/(.*) /v2/$1 
0
source

Source: https://habr.com/ru/post/1304497/


All Articles