Website that recognizes user's location/IP & changes lang. based on that

The title is pretty clear.

My website consists of both English-written and Spanish-written versions. You can go to the main site, which is in Spanish, by clicking and to the translated version, which is in English, at At the index of each page, there is a link (at the bottom) that allows the user to pass from one site to the other.

However, I was wondering, how big sites like Google, Yahoo!, and other brands' websites recognize the user's geographical location/IP so that - depending on that - the site's language is adapted (i.e. you are from China and you visit, you'll be redirected to

I have stated on every single page of my website the language:

<meta http-equiv="content-language" content="en">

That example is of course from one of the sites, which are in English.

I hope someone can give me a hand. Thank you (if I missed something, please let me know).


  • As for Google, your location is determined from your IP address. A request to from outside the US returns an HTTP/1.1 302 Found which redirects you to your country specific domain.

    As also discussed on another post, doing these kinds of redirects can make SEO tricky and complicated. I suggest reading Matt Cutt's article (a Google software engineer) on how Google handles the 302 Redirect: SEO advice: discussing 302 redirects.

    Different search engines handle the 302 redirect in a different way. With 302 redirects, you may risk having your original domain ignored by search engines.

    If you want to determine your users' location from their IP address, there are many off-the-shelf services which basically map most of the IP ranges to countries. You may want to check:

    Another popular technique is to parse the Accept-Language HTTP header, which contains information about the user's language preferences. Mainstream browsers allow these language preferences to be modified by the user. You may read more about this technique from: