Redirect based on browser language with .htaccess

Опубликовано 10 сент. 2014 г.

To redirect users to the domain page of a website according to the browser default language setting you can use the following .htaccess.

# French
RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.fr$ [NC]
RewriteRule ^$ http://www.domain.fr/ [R,L,NC]

# German
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.de$ [NC]
RewriteRule ^$ http://www.domain.de/ [R,L,NC]

# All other languages
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteRule ^$ http://www.domain.com/ [R,L]

Of course you can add/change/delete languages and domains according to your own needs.

Оставить комментарий

Это никогда не будет опубликовано.
Вы можете использовать Синтаксис Markdown. HTML не разрешен.