can anyone help me its urgent.

Discussion in 'PHP' started by mixtaka, May 29, 2010.

  1. #1
    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
     
    mixtaka, May 29, 2010 IP
  2. math.fox

    math.fox Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    this is hard job using .htccess
     
    math.fox, May 29, 2010 IP
  3. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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?
     
    JAY6390, May 29, 2010 IP
  4. mixtaka

    mixtaka Active Member

    Messages:
    267
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    i want this in whole site not just home page
     
    mixtaka, May 29, 2010 IP
  5. aTo

    aTo Active Member

    Messages:
    473
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    78
    #5
    
    <?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...
     
    aTo, May 29, 2010 IP
  6. mixtaka

    mixtaka Active Member

    Messages:
    267
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    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
     
    mixtaka, May 30, 2010 IP
  7. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #7
    Yeah this will work exactly as you think!
    Simply else you can Indian Start IP Begins with and Redirect too
     
    roopajyothi, May 31, 2010 IP