We have a website "www.testa-omega3.com" with 3 different languages (DE, EN, NL). Our default language is Dutch (NL), which is currently the main domain.
The DE and EN language are in a sub-directory:
When we enter the full url's in the browser it will show the correct page. The non-www for the DE and EN is not redirecting correctly.
These:
testa-omega3.com/en
testa-omega3.com/en/
testa-omega3.com/de
testa-omega3.com/de/
Are all redirecting to "www.testa-omega3.com"
Currently we have the following lines in our htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
What are we doing wrong?
It seems your (sub)domain matching is set up incorrectly. Your rewrite rule is based on the URL already being entered with the www subdomain when you actually want to match against the naked domain.
Changing the line
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
to
RewriteCond %{HTTP_HOST} ^domain\.com$
should work.
(Your rewrite condition doesn't work at all on my end btw.; the server I'm hosted with complains that it gets stuck in a loop.)
In my rewrite rule I couldn't get the {HTTP_HOST}
variable to work the way you (re)used it, but using the full domain name worked just fine:
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]