How do I create PHP GeoIP redirect ?

by 10 replies
16
I have a niche autotoblog that drives me about 100 italian visitors daily. My conversion rate is 1:200. I am not glad with that.

What I need to do is redirect all my italian visitors to a nice landing page I created and keep all other visitors and spiders on my autoblog.

I just need a simple php script. Italian IPs are redirected to another page while all other visitors must remain on the page where they arrive (must not be redirected in any way because my visitors come from my wordpress posts that are indexed by google and I dont wanna mess with the GoogleBot)

Your help would be deeply appreciated.
#programming #create #geoip #php #redirect
  • Hey there invest207. There are a few options here. Not sure how much programming you do but you can do this pretty easily by making a call to a geolocation webservice. There are a few API's out there that are free.

    Check these links out, they offer code examples as well:

    roshanbh(dot)com(dot)np/2008/07/getting-country-city-name-from-ip-address-in-php.html

    www(dot)ipinfodb(dot)com/ip_location_api.php

    freegeoip(dot)appspot(dot)com/

    www(dot)hostip(dot)info/use.html

    Replace the (dot) with an actual .

    Im not allowed to post links yet.
    • [1] reply
    • You don't need to look any further than the Warrior Forum: http://www.warriorforum.com/programm...s-country.html

      But, if you have your own server, you might find it best to install the mod_geoip module for Apache because it's a lot faster than the PHP module. Also, with the Apace module, you can do .htaccess based redirects.
      • [1] reply
  • Do you know where I can get one from? And also will my main site stay the same or will I need some index.php for the redirect?
    • [1] reply
    • Banned
      Sure, you can get a free GeoIP database from here:

      www . maxmind . com / app / geolitecity

      Commercial database is $370, but the lite version seems to work quite well, although not 100%. API and code is also very simple to work with. I'd recommend it!
  • Thank you for your reply! I have downloaded and made up a PHP file and all works well!

    Just one quick question which I find doesn't really work with me; Say if a user goes to the main domain and he/she is in the UK and gets directed to websitename.com/uk thats all good and works well but what if they click on a link for the usa? websitename.com/usa doesn't seem to forward them to the correct country.

    Is there some kind of fix for this?
    • [1] reply
    • Banned
      Best way I can suggest is add a cookie when they click the link, which overrides the IP lookup check.
      • [1] reply
  • Banned
    [DELETED]

Next Topics on Trending Feed

  • 16

    I have a niche autotoblog that drives me about 100 italian visitors daily. My conversion rate is 1:200. I am not glad with that. What I need to do is redirect all my italian visitors to a nice landing page I created and keep all other visitors and spiders on my autoblog.