Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a big problem with GeoIP. My website has the following structure


I use the MaxMind GeoIP module in Apache to redirect users to the appropriate site base on their country.

My problem is when a user from Italy visits if ge wants to change language and try to open, he is redirected back to How can I prevent redirection when a user selects a language.

share|improve this question

2 Answers 2

Forget geolocation - it's fundamentally flawed as you have noted. Browsers send an Accept-Language header, check that on your www. site and flip the user, once, to the language they say they prefer. On the subdomains, provide change-language links but do not do any checks.

I develop multi-lingual sites from Japan (read: do this a lot), my standard .htaccess rule for Japanese speakers looks like this:

RewriteCond %{HTTP:Accept-Language} ^ja.*$ [NC]
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule .* [L,R=301]
RewriteCond %{HTTP:Accept-Language} ^ja.*$ [NC]
RewriteRule .*{REQUEST_URI} [L,R=301]

And of course there's no database to deal with. Japanese speakers on vacation in Brazil will still see the page in Japanese.

share|improve this answer

I would use cookie for this on * Special cookie value (let's say lang) should only be set if user clicks on any of the flags. Now on when routing users to localized websites you first check if cookie with lang value is set, if so, you redirect to a page with lang specified in the cookie. If, however, such cookie would not exist, then your redirection should work as usual.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.