First of all, I've got a few domains pointing to the same webpage, each domain corresponfing to a different language. The webpage (Drupal) identifies the language using a /lang
parameter in the url (example.com/en
).
I need to redirect every domain to its corresponding language so I need something like:
- example.com -> example.com/en
- example.ru -> example.ru/ru
- example.fr -> example.fr/fr
I defined some rules in htaccess but they don't do what i expected:
# Rewrite --- http://www.example.com => http://www.example.com/en
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^$ /en? [L,R=301]
# Rewrite --- http://www.example.ru => http://www.example.ru/ru
RewriteCond %{HTTP_HOST} !^www\.example\.ru [NC]
RewriteRule ^$ /ru? [L,R=301]
Instead of changing example.com
to example.com/en
and example.ru
to example.ru/ru
it appends /en
to all domains.
Is it something I am missing?
Any advice would be very helpful.