1

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:

  • www.testa-omega3.com/de/
  • www.testa-omega3.com/en/

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?

Kara
  • 6,115
  • 16
  • 50
  • 57
Vincent
  • 13
  • 3
  • It's not entirely clear what you want to do. Should everyone get redirected to the www subdomain even if they didn't type that part into their browser? But the language "extension" should be kept IF it was provided? – Kay Oct 26 '15 at 22:38
  • testa-omega3.com/en should redirect to www.testa-omega3.com/en/ etc. etc. – Vincent Oct 27 '15 at 10:56

1 Answers1

0

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]
Kay
  • 797
  • 1
  • 6
  • 28
  • @Vincent, did this solve your problem? If so, could you accept the answer so your question gets marked as resolved? – Kay Nov 25 '15 at 00:43