We are looking for a way to redirect the visitors not in our country to our international website.

Firstly, we have to detect their location with a Geo-location service, and then redirect them if they are not a native visitor. But we do not want to harm our existing SEO while we are doing this.

Do we have to use 302 server-side redirection or a client-side redirection with JavaScript?

  • 1
    I have removed off-topic part of the question Commented Jan 24, 2014 at 12:37

2 Answers 2


But we do not want to harm our existing SEO while we are doing this.

What you might be concerned here with is Cloaking - that is, serving different content to a user's browser than to search engine robots.

Providing that you use IP delivery, which is using the requestor's location to deliver content specifically written for that country, versus redirecting based on user agent, you should be fine as indicated here:

Many of the top 1000 sites, including sites like Amazon (amazon.com), actively use IP delivery. None of these have been banned from search engines as their intent is not deceptive.

You should probably also be aware of issues related to serving duplicate content between your international and country-specific website, should they contain the same content, which can be addressed with canonicalization and geotargeting your content.

To accomplish redirection with IP delivery, it would be wise to use a service that provides GeoIP databases which are routinely updated, such as MaxMind's GeoIP Country Database. You can implement that using server-side APIs in the following languages:

  • PHP
  • Python
  • Perl
  • Ruby
  • Java
  • C#
  • C ...

Many of these have easy to use open source modules too. For example, I use this PHP extension: Geo IP Location, as well as this Perl module: GEO-IP.

There's a free version of the database, GeoLite, which is updated once a month, and a more accurate paid version, GeoIP Country, that gets updated more frequently.

There's also a JavaScript Client API, available in a paid and free version (the free version only requires an attribution statement on your website). This combines both W3C Geolocation and their GeoIP2 Web Service, which first attempts to get the visitor's location from their browser, and if not available or inaccurate, it then uses a GeoIP lookup.

In addition to the sample code, there's a tutorial on how to use the API here: GeoIP2 JavaScript Tutorial

Do we have to use 302 server side redirection or a client-side redirection with JavaScript?

A 302 redirect would indicate the page was "Moved Temporarily", which is not really the case here. Implementing either the server-side APIs or JavaScript above would be sufficient.

As to which to use, the server-side versus client-side JavaScript, that depends on whether you want to perform actions on your server related to the redirection, such as displaying country-specific content, ads, etc... The benefit with JavaScript is that it reduces server resources, however, if JavaScript is disabled in the user's browser, the redirection can't occur unless their location is provided by their browser (see above). It's always wise to provide a "Country" link in your website's navigation for that reason.


This page from Google webmaster tools might help you.

On the top of the page include links to both versions of your site so that users will be able to switch between them and also search engines would be able to access them.

The best solution according to me is to detect the user's location using JavaScript and if they are not on the correct version, display a message asking if they want to be redirected to the regional / international version of the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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