I need a redirection script that will redirect all USA traffic to one page and every other to another. let me know. I need this ASAP so whoever can help Gets rep whenever I see your post lol
I need a redirection script that will redirect all USA traffic to one page and every other to another. let me know. I need this ASAP so whoever can help Gets rep whenever I see your post lol
Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28
Download the appropriate files for php here: maxmind.com
This should do the trick
Code:<?php include("geoip.inc"); $ip=$_SERVER['REMOTE_ADDR']; $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, "$ip"); geoip_close($gi); switch($country_code) { case "US": header("Location: http://US-URL"); break; default: header("Location: http://RestOfTheWorld-URL"); } ?>
sapo (12-17-2011)
Thanks But I couldent figure it out, Just gives me a blank page no redirection happens
Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28
Are the geoip.dat and geoip.inc files both inside the same folder as the page?
sapo (12-17-2011)
Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28
now both the files are in the same folder but still no redirection just blank
Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28
Could you paste the entire code you have here?![]()
its the same as that person provided
and i have geoio.inc and GeoIP.dat in the same directory as this index.html fileCode:<?php include("geoip.inc"); $ip=$_SERVER['REMOTE_ADDR']; $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, "$ip"); geoip_close($gi); switch($country_code) { case "US": header("Location: http://yahoo.com"); break; default: header("Location: http://google.com"); } ?>
Juan ManuelMarquez Do you have targetted Traffic? AnyNiche I can Monetize it. Avg EPC .28
The code works great, just retested on one of my servers OP.
1. Delete the 2 files geoip.inc and GeoIP.dat you have now (maybe tainted?)
2. Make sure you get the geoip.inc from here:
http://geolite.maxmind.com/download/.../php/geoip.inc
3. get geoip.dat.gz (that you'll decompress so you'll end up with GeoIP.dat) from here:
http://geolite.maxmind.com/download/...y/GeoIP.dat.gz
Retry and it'll work for sure.
HTH!
sapo (12-18-2011)
Are you using this on an html page? You shouldn't be able to see any source code when you load the page in your browser from your web server. Your page must have a .php file extension and you should be inserting that code before the opening <html> tag. You must test this on a web server - just opening the page in your browser from your local hard drive won't parse the php code.
If you want to parse .html files for php includes, you can set that up in your .htaccess file (google "parse php in html htaccess").
"An ounce of action is worth a ton of theory." - Ralph Waldo Emerson
sapo (12-18-2011)
Oh wow, that's hilarious. lol Glad everything worked out.![]()
sapo (12-18-2011)
Checklist:
1. You put the above code into a file with a php extension, right (not htm/html)?
2. You are testing this with a hosting that actually supports php (you never know...)?
3. To do some infamous "printf debugging" change this part 'header("Location: http://yahoo.com");' with 'echo "I am a US visitor";' and see if it shows up.
If this is not the case it eludes me how such a simple snippet wouldn't work for ya.
sapo (12-18-2011)
Bookmarks