Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery code redirect page according to visitor ip

I have www.propertyhere.com

I want to insert some Jquery code in the index page to redirect visitor into the following pages according to their geographical ip location.

 if user ip is from AU then show:
 http://www.propertyhere.com/Country/AU/search-to-buy;

 if user ip is from CA then show:
 http://www.propertyhere.com/Country/CA/search-to-buy;

 if user ip is from NZ then show:
 http://www.propertyhere.com/Country/NZ/search-to-buy;

 if user ip is from US then show:
 http://www.propertyhere.com/Country/US/search-to-buy;

 if user ip is from CN then show:
 http://www.propertyhere.com/Country/CN/search-to-buy;

 if user ip is from RU then show:
 http://www.propertyhere.com/Country/RU/search-to-buy;

If visitor's ip doesn't match the above locations then just let the visitor stay in the homepage.

like image 730
wang hai peng Avatar asked Nov 20 '25 19:11

wang hai peng


1 Answers

You could use a service such as http://geoiplookup.wikimedia.org/ and do a simple ajax request. This should grant you all the necessary details.

dome thing like this may help:

$.ajax('http://geoiplookup.wikimedia.org/', {
    crossDomain:true,
    success:function(data,text,xhqr){
        alert(data);
    },
    error:function(xhr, textStatus){
        alert(xhr.responseText);
    }
});
like image 188
Mortalus Avatar answered Nov 23 '25 08:11

Mortalus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!