How do I create PHP GeoIP redirect ?

10 replies
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.
#create #geoip #php #redirect
  • Profile picture of the author 723Media
    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.
    {{ DiscussionBoard.errors[1190134].message }}
    • Profile picture of the author mojojuju
      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.
      Signature

      :)

      {{ DiscussionBoard.errors[1190298].message }}
      • Profile picture of the author bl4ck-dollar
        Hey,

        Sorry to bring up a really old thread but did a search and thought it would be better than starting a new. Anyhow...

        I currently have a wordpress squeeze page; I would like to know if it is possible to redirect visitors based upon country but keep the main page in other words not have to make index2.php etc etc. Would it mean me having to produce say 5 wordpress pages just to have them redirect? and would this effect my SEO ranking at all becuase all pages would effectivly be dupes. So you would have usa.salespage.com , uk.salespage.com and so fourth.

        Does anyone have any ideas at all on this?
        {{ DiscussionBoard.errors[2131340].message }}
        • Profile picture of the author Guide
          Originally Posted by bl4ck-dollar View Post

          Hey,

          Sorry to bring up a really old thread but did a search and thought it would be better than starting a new. Anyhow...

          I currently have a wordpress squeeze page; I would like to know if it is possible to redirect visitors based upon country but keep the main page in other words not have to make index2.php etc etc. Would it mean me having to produce say 5 wordpress pages just to have them redirect? and would this effect my SEO ranking at all becuase all pages would effectivly be dupes. So you would have usa.salespage.com , uk.salespage.com and so fourth.

          Does anyone have any ideas at all on this?
          If all pages are the same, why do you even want to create duplicates?

          If the content & offers on each of those pages are going to be different, then it makes sense. You will need a geo-database API or the actual geo DB for this.
          {{ DiscussionBoard.errors[2132160].message }}
  • Profile picture of the author bl4ck-dollar
    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?
    {{ DiscussionBoard.errors[2132238].message }}
    • Profile picture of the author kiopa
      Banned
      Originally Posted by bl4ck-dollar View Post

      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?
      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!
      {{ DiscussionBoard.errors[2138313].message }}
  • Profile picture of the author bl4ck-dollar
    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?
    {{ DiscussionBoard.errors[2138449].message }}

Trending Topics