I've got a website www.abc.com that has this content for the country X. Also I've another site target to various country Y on the subdomain of the exact same domain like subdomain.abc.com

I'm able to use any free geo ip database plus some php script to achive the redirection and that i did this effectively however the issue is

Person from country Y going to the website www.abc.com has been rerouted to subdomain.abc.com but he's suppose wish to check www.abc.com it again redirects these to subdoamin.abc.com.

I would like this the google way, to ensure that if suppose an individual going to google.com from UAE has been rerouted to google.ae but when they click go to visit Google.com they're rerouted to google.com with no problem.

I have to implement this for my website..

The website is within wordpress. Please suggest me the perfect solution.

Ok This is a code that I have tried personally..

/**
 * Example 6
 *
 * This is what google probably do with users around the world
 *
 * Multiple declatations
 */

// Start by including CountryDetector class
include("./src/CountryDetector.class.php");

// You dont need to create instance of this class you can access only on static context

// Google.co.uk
CountryDetector::redirect("AE", "http://uae.jobscow.com");

// Google Germania
CountryDetector::redirect(array("DE", "AT"), "http://google.de"); // Ausrian and German users

// Google China
CountryDetector::redirect("CN", "http://google.cn");

// Google sweden
CountryDetector::redirect("SE", "http://google.se");

// Google norwegia
CountryDetector::redirect("NO", "http://google.se");

// Google serbia
CountryDetector::redirect("RS", "http://google.rs");

// AND SO ON...

// Finally: Google.com - international
CountryDetector::redirect("international", "http://google.com");

?>

What changes can you suggest me to create within this

  1. Install GeoIP PHP Extension http://www.videochat-scripts.com/install-geoip-php-extension/
  2. Identify user's country http://php.net/manual/en/book.geoip.php
  3. Redirect user if he arrived on wrong site

Use referer check: when they arrive on www.abc.com and referer isn't the country site, redirect to country site.

When they click "visit www.abc.com" around the country site, the referer is going to be country.abc.com, and you don't redirect.

You might make use of a cookie to keep a customer's preference within this matter.

RFC2616 section 14.36 describes the Referer header area, and this article shows using it in php.

EDIT: as a substitute - because when lars states the consumer or something like that across the path could deactivate it / take away the header - you could utilize an online "website landing page" on www.abc that hints the server the customer originated from the nation server:

<a href="www.xyz.com/fromcountryserver.php">Go to xyz</a>

or why don't you, give a request variable that signifies the browser originated from the nation server. Silly example simply to show the intention

<a href="www.xyz.com/index.php?comingfrom=countryserver">Go to xyz</a>

or a mixture of they. A little more work but unless of course some maniac rewrites Web addresses clientside it will always work.

In my opinion it is simply a cookie that Bing is using with this silly trick.

Allow me to suggest you to definitely navigate to google although some HTTP sniffer on. That's very educational enterprise.