I would like to know what's the best method to redirect a site depending on the browsers language settings.
I want to redirect the following browser locales to /es:
es-ar, es-co, es-cu, es-do, es-gt, es-ht, es-mx, es-ni, es-pe, es-pr, es-sv and of course es and es-es
i know it could be done via .htaccess but the following did not work at all:
RewriteCond %{HTTP:Accept-Language} (es|es-ec|es-mx|es-co) [NC]
RewriteRule .* http://www.%{HTTP_HOST}/es/ [R,L]
but I think the best would be to do this in the index.php template:
in the /index.php I would need some sort of redirection upon language detection but my php skills are very limited, so maybe someone can show me the right path:
something like:
if ($_SERVER['HTTP_ACCEPT_LANGUAGE'] = "es|es-es|...")
{
// header( 'Location: http://${_SERVER['HTTP_HOST']}/es/');
//please help!
};
any help appreciated!
cheers
stefan