I want to redirect domain www.A.com to www.B.com all over the world except India. im using wordpress for my both domain. both site are now live. im using - Linux server with the Apache Mod-Rewrite module enabled
This isn't going to work with .htaccess alone. you will need to rewrite all URLs through a script and check if the country is india in that script, redirecting to the new site if it is, and serving up the url if it isn't. Is this for just a homepage or the whole site you are wanting to be redirected?
<?php function countryCityFromIP($ipAddr) { //function to find country and city from IP address //Developed by Roshan Bhattarai http://roshanbh.com.np //verify the IP address for the ip2long($ipAddr)== -1 || ip2long($ipAddr) === false ? trigger_error("Invalid IP", E_USER_ERROR) : ""; $ipDetail=array(); //initialize a blank array //get the XML result from hostip.info $xml = file_get_contents("http://api.hostip.info/?ip=".$ipAddr); //get the city name inside the node <gml:name> and </gml:name> preg_match("@<Hostip>(\s)*<gml:name>(.*?)</gml:name>@si",$xml,$match); //assing the city name to the array $ipDetail['city']=$match[2]; //get the country name inside the node <countryName> and </countryName> preg_match("@<countryName>(.*?)</countryName>@si",$xml,$matches); //assign the country name to the $ipDetail array $ipDetail['country']=$matches[1]; //get the country name inside the node <countryName> and </countryName> preg_match("@<countryAbbrev>(.*?)</countryAbbrev>@si",$xml,$cc_match); $ipDetail['country_code']=$cc_match[1]; //assing the country code to array //return the array containing city, country and country code return $ipDetail; } ?> PHP: found that script... i guess it may help, i dunno if it is 100% accurate... but giving it a try won't hurt... use that this way... <?php if(countryCityFromIP($_SERVER['REMOTE_ADDR']) == "India")//not sure bout this part... try to check... :) header("location:http://www.B.com"); ?> PHP: place the code above every page... hope it helps...
First thanks all of you for your suggestion, im newbie in script, so you should tell me step by step process. hope i found anyone who help me step by step
Yeah this will work exactly as you think! Simply else you can Indian Start IP Begins with and Redirect too