I created a multilanguage site with URLs that have language codes in them.
It looks like this:
sub1.example.com/en/
sub1.example.com/en/this-is-page-in-english
sub1.example.com/de/
sub1.example.com/de/this-is-page-in-german
sub1.example.com/pl/this-is-page-in-polish
sub2.example.com/en/
etc.
Because English is the main language, I would like to redirect those URLs to these URLs:
sub1.example.com/
sub1.example.com/this-is-page-in-english
sub1.example.com/de/
sub1.example.com/de/this-is-page-in-german
sub1.example.com/pl/this-is-page-in-polish
sub2.example.com/
In other words, redirect all English pages to the main pages, for all subdomains.
Thanks
You can use the following rule to redirect /en
URLs to the main sub domain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^((?!www).+)\.example\.com$ [NC]
RewriteRule ^en/(.*) https://%{HTTP_HOST}/$1 [NE,L,R=301]
Don't forget to replace example.com
with your yourdomain.com
.