View Full Version : .htaccess - if redirect from xyz.net rewrite browser language to spanish

06-26-2011, 12:36 PM
Hello, I would like to rewrite the browser language in htaccess is it possible?


there is the domain xyz.com and the language of the site is English;
there is the domain xyz.net that redirects to xyz.com;

If somebody enters xyz.com from a redirect of xyz.net and their browser language is English, I would like the htaccess to change/rewrite the browser language to Spanish.

Is it possible?

I'll have a plugin that translates to Spanish according to the browser language, but I want ALL users coming from xyz.net see the spanish version even if they have the browser in English.

07-08-2011, 11:46 PM
You could do this for the first hit to the site by checking the HTTP_REFERER, but as soon as they click around the site the referer would no longer be the .net address but the .com address. The only solution that springs to mind would be setting a cookie on the users machine if the refererer is the .com address and checking the cookie in your scripts. It is worth baring in mind though that there is new european legislation about the use of cookies, that could potentially make this a very dark grey area. The only other solution is to have some reference to the language stored in the url, such as using a different sub-domain etc.