Home > Blockchain >  Redirect to main url from language subfolder url with TranslatePress
Redirect to main url from language subfolder url with TranslatePress

Time:12-09

I had added Translatepress to my website for multilanguage and have the option enabled (add subdirectory to url for languages). so the url was mydomain.de/de mydomain.de/en

Now i have removed the Translatepress but some trafic still comes with subdirectory /de/ or /en/ I wants to redirect all urls from /de/ or /en/ to main url (mydomain.de).

How can i do this with .htaccess or by other means ?

CodePudding user response:

I tried something, dont know if its good. but hope it will help some others.

So, the main language or my site is DE do, i redirected all links from /de/ to main url and from /en/ through 410

RewriteEngine On
RewriteRule ^en/(.*) https://%{HTTP_HOST}/$1 [NE,L,R=410]
RewriteRule ^de/(.*) https://%{HTTP_HOST}/$1 [NE,L,R=301]

you can replace 410 with 301 if you wants to redirect /en/ to main url too.

  • Related