Auto-redirect with .htaccess ends in loop

I am trying to setup auto-redirect based on user’s browser language (web structure is root/en, root/de) with .htaccess file.

Here is my code:

RewriteEngine on
#RewriteCond %{HTTP:Accept-Language} (de) [NC]
#RewriteRule .* [R,L]
#RewriteCond %{HTTP:Accept-Language} (en) [NC]
#RewriteRule .* [R,L]

When I set this up, the whole web becomes unaccessible with every browser saying something like “redirect loop, page unavailable”.

Both folders don’t redirect anywhere, so I have no idea why this is happening. Any idea?


Have you setup multi-context in MODX to capture the /de and /en ? Otherwise if they don’t exist then it’ll try to take you to the homepage, which is then trying to redirect them to the folder, and that’s where you’ll be getting your loop.

Umn, how do I setup multiple contexts in this case?

Take a look at this article. Any questions feel free to ask.

Another option is to use