views:

54

answers:

4

I had two domains. rajasekar.com and rajasekar.in. What I need to do is that,

when a user from India types the url in the address bar as www.rajasekar.com then it should open www.rajasekar.in

When user from other country types the url in the address bar as www.rajasekar.com it should open www.rajasekar.com

I think this is what implemented in GOOGLE. Please help me in achieving this

+2  A: 

this can help, http://www.maxmind.com/app/geoip_country

jspcal
+2  A: 

In ASP.NET, get the client's IP address using :

Request.ServerVariables("REMOTE_ADDR")

Use some IP to geo location service like :

  1. Maxmind
  2. IPAddressExtentions

Once you get the country, you can easily redirect the user :

 Response.Redirect("http://www.yourdomain.in")
H Sampat
I believe he wants a PHP specific solution.
Alix Axel
+1  A: 

Here is a fully working solution, you'll have to work the redirection logic though:

$country = trim(file_get_contents('http://api.hostip.info/country.php?ip=' . $_SERVER['REMOTE_ADDR']));

if ($country == 'IN')
{
    header('Location: http://www.rajasekar.in/'); die();
}
Alix Axel
thanks, do u know other ipaddress lookup other than hostip.info
Rajasekar
@Rajasekar: MaxMind.com, but they don't provide a free API.
Alix Axel
A: 

The Accept-Language request header will tell you what language/region the user has their browser set to.

ishanrc