.htaccess: redirect root wordpress url to another wordpress in a subdirectory, but keep the root URL

I want to do a www.site.it redirect to use site.it/v2/, but still display as site.it in the URL.

My .htaccess at www.site.it

RewriteEngine On RewriteCond %{THE_REQUEST} ^GET\ /v2/ RewriteCond %{HTTP_HOST} ^(www\.)?site.it$ RewriteRule ^v2/(.*) /$1 [L,R=301] RewriteCond %{HTTP_HOST} ^(www\.)?site.it$ RewriteRule !^v2/ v2%{REQUEST_URI} [L] 

and redirection works.

my .htaccess at www.site.it/v2/is

 Options +FollowSymlinks RewriteEngine On #Force removal of www subdomain RewriteBase / RewriteCond %{HTTP_HOST} ^www.site.it RewriteRule ^(.*)$ http://site.it/$1 [R=301,L] #Trailing slash RewriteRule ^/*(.+/)?([^.]*[^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301] #Redirect root url to subdirectory RedirectMatch 301 ^/v2/$ http://site.it RewriteRule ^$ /v2/?$ [L] 

it removes 'v2', but at the same time redirects to the old site at www.site.it , so this is wrong.

I want to do a www.site.it redirect to use site.it/v2/, but still display as site.it in the URL.

0
source share

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


All Articles