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
You can try to guess the country based on the remote address of the user.
The following is a working solution, you'll have to work the redirection logic though:
$remoteAddr = $_SERVER['REMOTE_ADDR'];
$lookupUrl = sprintf('http://api.hostip.info/country.php?ip=%s', $remoteAddr);
$country = trim(file_get_contents($lookupUrl));
if ('IN' === $country)
{
$newUrl = 'http://www.rajasekar.in/';
header(sprintf('Location: %s', $newUrl));
printf('Moved.', $newUrl);
exit();
}
Take care that search engine robots from India are able to crawl the .com content as well however.