URL REDIRECTION - BASED ON LOCATION

Discussion in 'Link Development' started by SmartestSmarty, Jan 5, 2014.

  1. #1
    Hello,

    Can some one help me please - I would much appreciate it.

    Lets say for example, I have a product for sale on a store in the UK (1st URL), and a Product for sale in a store in the US (2nd URL).

    They are both the same site, but are under two different URLs.
    Is it possible, to create a single URL, which would direct the person who clicks it to the appropriate URL based on their location?

    Any advice would be appreciated.
     
    SmartestSmarty, Jan 5, 2014 IP
  2. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    406
    Best Answers:
    21
    Trophy Points:
    295
    #2
    What cart system are you using? That sounds a tad vexing but geo ip stuff is not so bad really. It would make more sense to have a .co.uk version of the site .com version etc. it becomes a bit more complex when you have both on one domain.

    Nigel
     
    Nigel Lew, Jan 5, 2014 IP
  3. SmartestSmarty

    SmartestSmarty Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Thanks for your reply

    I use wordpress.com.
    Not sure how to install plugins on that.

    The products I was referring to are on amazon.co.uk and amazon.com, I have no control over these domains.

    I simply want to create links, which I can put on my social media sites, which will redirect users based on their location.
     
    SmartestSmarty, Jan 5, 2014 IP
  4. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    406
    Best Answers:
    21
    Trophy Points:
    295
    #4
    That redirection would in theory get handled on amazons end off the top of my head. I dont think you push basically, there is no inherent detection going on until the amazon server is pinged. But, if you have a hard link to a .com that is where the visitor is going. What happens later is out of your control I would imagine.

    Nigel
     
    Nigel Lew, Jan 5, 2014 IP
  5. SmartestSmarty

    SmartestSmarty Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Quite hard for me to understand, but yes I only have .com or .co.uk links.

    Do you think they could provide me links which redirect?
     
    SmartestSmarty, Jan 5, 2014 IP
  6. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    406
    Best Answers:
    21
    Trophy Points:
    295
    #6
    http://www.kboards.com/index.php?action=printpage;topic=159406.0

    There is a discussion about this there. I have to run out for a sec so I am not entirely focused but it seems to me amazon is probably already doing this anyway. If I click a .co.uk link I would think amazon will throw me to the US iteration of the site since that is where I am.

    This may be a non issue.
    Nigel
     
    Last edited: Jan 5, 2014
    Nigel Lew, Jan 5, 2014 IP
    sarahk likes this.
  7. SmartestSmarty

    SmartestSmarty Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    For some reason Amazon don't. I am in the UK if I click on a .com link it takes me to the .com store.
     
    SmartestSmarty, Jan 6, 2014 IP
  8. SubediK

    SubediK Active Member

    Messages:
    63
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    83
    #8
    It is totally possible. There will be different ways to do it depending on what type of site it is.

    You can use a free GEOIP database (there is one by company called maxmind) and check where the user is viewing from. Then its just a matter of doing a 302 header redirect to the right url depending on the location.

    If you are running apache with mod_geoip (or if your host supports that) then its even easier, check this thread out http://stackoverflow.com/questions/9838344/how-to-redirect-domain-according-to-country-ip-address

    Good luck!
     
    SubediK, Jan 6, 2014 IP
  9. SmartestSmarty

    SmartestSmarty Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #9
    Hello,

    Sorry I do not have a host, I want to use these links on social media sites, e.g. Twitter and Facebook.
     
    SmartestSmarty, Jan 6, 2014 IP
  10. SubediK

    SubediK Active Member

    Messages:
    63
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    83
    #10
    Save the code below as a php file and change the top part with the URLs you want then link to that php file.
    <?PHP
    
    //Change the values below
    
    $usa = "http://usa.com";
    $uk = "http://uk.com";
    $others = "http://nepal.com";
    
    function visitor_country()
    {
        $client  = @$_SERVER['HTTP_CLIENT_IP'];
        $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
        $remote  = $_SERVER['REMOTE_ADDR'];
        $result  = "Unknown";
        if(filter_var($client, FILTER_VALIDATE_IP))
        {
            $ip = $client;
        }
        elseif(filter_var($forward, FILTER_VALIDATE_IP))
        {
            $ip = $forward;
        }
        else
        {
            $ip = $remote;
        }
    
        $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
    
        if($ip_data && $ip_data->geoplugin_countryName != null)
        {
            $result = $ip_data->geoplugin_countryName;
        }
    
        return $result;
    }
    
    
    $loc = visitor_country();
    if($loc == "United States"){
        header("Location: $usa");
    }elseif($loc == "United Kingdom"){
        header("Location: $uk");
    }else{
        header("Location: $others");
    }
    ?>
    
    PHP:
    It uses free geoip database from geoplugin.net.
    Let me know if it works.
     
    SubediK, Jan 6, 2014 IP
  11. SmartestSmarty

    SmartestSmarty Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #11
    What do you mean by save it as a PHP file?
     
    SmartestSmarty, Jan 6, 2014 IP
  12. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    406
    Best Answers:
    21
    Trophy Points:
    295
    #12
    I don't think he is listening but, in all fairness, I thought you were running an affiliate site as well.

    Nigel
     
    Nigel Lew, Jan 6, 2014 IP
  13. SubediK

    SubediK Active Member

    Messages:
    63
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    83
    #13
    Sorry forgot to mention, get a free web host that supports php and save this file there. I don't know if any other websites that provide this kind of service so looks like you will have to use your own.
     
    SubediK, Jan 6, 2014 IP