Q:

htaccess language detection and redirect: redirect loop issue

I'm not really a pro in modifying .htacess files so I used http://www.htaccesstools.com/redirection-by-language/ generator to create redirect for different languages. 
It should have two options: redirect to "ru" folder if browser language is russian and all other languages go to default page in english. However, it seems I just don't get it right and it also causes redirect loop.
Code looks like this:
RewriteEngine on
RewriteCond %{HTTP:Accept-Language} (ru) [NC]
RewriteRule .* %sitename%/ru/index.html [R,L]

It would be also if redirect will be disabled if user changes language manually using selector. Thanks in advance.

A:

Make sure these rules are your very first rules:
RewriteEngine on

RewriteCond %{HTTP:Accept-Language} ru [NC]
RewriteRule !^ru(/.*)?$ /ru/index.html [R,L,NC]

RewriteCond %{HTTP:Accept-Language} !ru [NC]
RewriteRule ^ru(/.*)?$ /index.html [R,L,NC]

