GeoIP Redirect Script /w Maxmind Free Database (non-JS version)

Tried a few scripts before but there never seemed to work properly.

This one does! Thnx man u saved me alot of work :D
 
Script works great. Thanks.. I did notice that when I try to download the zip file and unzip that I get this never-ending loop of zip files instead of the actual redirect script. I did some digging around was able to come up with the inc file from maxmind's site, which works. You can find that file tucked away in this download

[h=3]Index of /download/geoip/api/php/[/h]
 
anybody knows how to add a rotating function?
Like each US traffic get redirect to a group of links that are routed?

Thanks
Example
1st visitor from us go to link1, 2nd go to link 2, 3rd go to link 3, etc, so to be able to split test landing pages.
 
This you can do with bevomedia for free.
one tracking url that can redirect from geo targeting, dayparting, OS, browser

you can make as many links as you want.
IxUhz
 
I wonder if it would be possible to use this with the city database instead of country database
 
This you can do with bevomedia for free.
one tracking url that can redirect from geo targeting, dayparting, OS, browser

you can make as many links as you want.
IxUhz

I don't use Bevomedia for the fact that the GEO redirection script is hosted on their server... call me paranoid but I try to host everything on my own server including tracking links, adserver, analytics etc... they do have a self-hosted version but last I heard will cost around $500.
 
I wonder if it would be possible to use this with the city database instead of country database

never tried using the city DB but some modifications will need to be done on the script, try to search the forum to see if there is any city GEOIP version.
 
Finally, I can make use of these foreign leads I keep getting. I get like 50% foreign traffic that isn't paying jack squat right now, but now I can make use of them bwahaha.
 
could someone help me? I've got the script installed and it appears to be working. I tried to test the script by faking my location, but the scripts just redirects me to the the first link (in my case the us link). The link's landing page knows that i'm "not" from the us (I was spoofing my ip for the UK), but why didn't it go to the link for UK/GB? Thanks!
 
could someone help me? I've got the script installed and it appears to be working. I tried to test the script by faking my location, but the scripts just redirects me to the the first link (in my case the us link). The link's landing page knows that i'm "not" from the us (I was spoofing my ip for the UK), but why didn't it go to the link for UK/GB? Thanks!

First go to Maxmind site to download the latest database, if the script still redirects you to the US landing page(everything sets up correctly), this means the database's mistakenly consider that IP comes from the US. You can either update the database manually to correct this error, or just live with it. It's not 100% accurate, but it's the best we can get for free. On my 2 VPS it also can't recognize them as US IPs. So probably you have to live with it, or pay for more accurate database.

By the way, it could also be your spoofing not working, so you better double check it with some other VPS.
 
First go to Maxmind site to download the latest database, if the script still redirects you to the US landing page(everything sets up correctly), this means the database's mistakenly consider that IP comes from the US. You can either update the database manually to correct this error, or just live with it. It's not 100% accurate, but it's the best we can get for free. On my 2 VPS it also can't recognize them as US IPs. So probably you have to live with it, or pay for more accurate database.

By the way, it could also be your spoofing not working, so you better double check it with some other VPS.

Thanks i'll look into it.

Also how is the best way to spoof you ip and location?
 
could someone help me? I've got the script installed and it appears to be working. I tried to test the script by faking my location, but the scripts just redirects me to the the first link (in my case the us link). The link's landing page knows that i'm "not" from the us (I was spoofing my ip for the UK), but why didn't it go to the link for UK/GB? Thanks!

Exact same problem
Latest database downloaded but with UK IP redirects to UK but with
US-NON US- Europe-Canada-Any other IP redirects to ONLY USA which is wrong!


So this doesn't worked


UPDATE:

I found the solution!!
This line not works well and doesn't return actual IP in 90% of today servers!!!

$ip=$_SERVER['REMOTE_ADDR'];


Replace it with this function!!

Code:
function getRealIpAddr()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}
AND ALL WORKS NOW!!
 
Last edited:
Does someone has the latest geoip file in zip format ?
Right now you can download the latest version as gz only
Code:
http://dev.maxmind.com/geoip/geoip2/geolite2/
 
Thanks man, you saved me some serious hours of coding; now I can just drop this in a framework!
 
thanks great post just tried it out and works amazing!! needed something like this desperately and saved me some money and time thanks man :)
 
Back
Top