![]() | | ||||||||
| | #1 |
| Advanced Warrior War Room Member Join Date: Jan 2009
Posts: 544
Thanks: 155
Thanked 230 Times in 50 Posts
| How can I redirect traffic based on the visitor's country? The title is quite self-explanatory. What I want to do is redirect traffic from certain countries to another web page. More specifically, what I want to do is redirect all the traffic to a web page "X", EXCEPT traffic coming from countries ("A" | "B" | "C"), that will be redirected to another web page "Y". I've found some possible solutions, such as MaxMind's API: GeoIPCountry (GeoLiteCountry): MaxMind - GeoIP Apache API But, I'm a member of BlueHost and they do not support mod_geoip I'm not sure if that is 100% necessary to make it work, since there are other API's available too (PHP, etc.) Is there any other way to successfully do this? Does anyone know where I can get step-by-step instructions on how to do this? I don't really know anything about coding/scripting Any help would be appreciated. Finding a solution to this is really important for me right now! Thanks in advance, Pablo |
![]() GOOGLE SAYS: FASTER WEBSITES RANK HIGHER AND MAKE MORE MONEY! Learn WHY and HOW! 390 SOLD in 72HS!! RAVE (+REAL) WARRIOR REVIEWS! | |
| | |
| | #2 |
| Advanced Warrior War Room Member Join Date: Jan 2009
Posts: 544
Thanks: 155
Thanked 230 Times in 50 Posts
|
Ok, I've been searching a lot and I have found this possible solutions. Both use PHP and GeoLiteCountry data to function: 1) Source: Site 2nd Geoip-php script to redirect user based on country I got problem to install mod_geoip in my server. So I use the most simple method to redirect users. I just use a php script to do it. Here is a script to redirect user based on their countries by using geoip.dat. [sourcecode language='php'] /** * Case Study - GeoIP Redirection * * @version $Id$ * @package geoip * @copyright © 2006 Lampix.net * @author Dragan Dinic */ require_once(”geoip/geoip.inc”); $gi = geoip_open(”geoip/GeoIP.dat”,GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if($country_code == ‘CS’) { header(”HTTP/1.1 301 Moved Permanently”); header(’Location: http://www.example.net/1/’); } else { header(”HTTP/1.1 301 Moved Permanently”); header(’Location: http://www.example.net/2/’); } ?> [/sourcecode] Change the geoip/geoip.inc and geoip/GeoIP.dat path accordingly. Change if($country_code == ‘CS’) to your desire country code. Change header(’Location: http://www.example.net/1/’); to your desire URL. That’s it! Easy! 2) Source: How-to use maxMind GeoIP for websites | PHP Forums Sometimes you need to redirect visitors based on the country they come from. Maxmind provides a great country/IP address database in binary format. The following example will show you how redirect visitors from countries which are not on the "whitelist". Download the latest Geo data and the class file here Copy the class file and the GeoIP data file into the same directory where the page is located (most of the time the root directory) Include the class file inside your page and add the following code to request the country using the following code (below the include statements): $gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE); $country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); Define some country codes the "whitelist": $my_countries = array('us', 'ca', 'gb', 'fr', 'de', 'nl'); Next place the following code below the $mycountries array: if (!in_array(strtolower($country), $my_countries)) { header('Location: some URL...'); exit; } ========================================= ========================================= Guys! I did it! Ok, so, just to let you know, this is how I did it: I don't really have ANY experience with PHP, but I started searching everywhere to find a solution. And this seems to have worked: First, I downloaded MaxMind's GeoIP.dat database from here: http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz Free Version (GeoLiteCountry) Then I downloaded geoip.inc from here: http://geolite.maxmind.com/download/.../php/geoip.inc Then I uploaded those two files to the same directory where my page is located. I edited my php page and wrote this script inside of it: Code: <?php
require_once('geoip.inc');
$gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE);
$country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);
$my_countries = array('us', 'ca', 'gb', 'fr', 'de', 'nl');
if (!in_array(strtolower($country), $my_countries))
{
header('Location: http://www."ALL"TRAFFICURLGOESHERE.whatever');
}
else
{
header('Location: http://www."SELECTEDCOUNTRIES"URLGOESHERE.whatever');
}
?> $my_countries = array('us', 'ca', 'gb', 'fr', 'de', 'nl'); and the URLs for both the targeted traffic and rest traffic where mentioned. Country Codes can be found here: MaxMind - ISO 3166 Country Codes Woalah! Hope this helps! |
![]() GOOGLE SAYS: FASTER WEBSITES RANK HIGHER AND MAKE MORE MONEY! Learn WHY and HOW! 390 SOLD in 72HS!! RAVE (+REAL) WARRIOR REVIEWS! | |
| | |
| | #3 |
| SocialAdr.com War Room Member Join Date: Apr 2009 Location: San Diego
Posts: 318
Thanks: 56
Thanked 29 Times in 27 Posts
|
I just setup the MaxMind free geo redirect script too - works great! ![]() I'm using it to redirect visitors to either Amazon US, Canada, UK, Germany, France, or China. |
| | |
| | |
| | #4 |
| Warrior Member Join Date: Jan 2009 Location: Canada
Posts: 22
Thanks: 13
Thanked 1 Time in 1 Post
| |
| | |
| | |
| | #5 |
| Warrior Member Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
Hi guys, This is exactly what I want... however it doesn't seem to work. I have uploaded the two files to my site - GeoIP.dat, geoip.inc I have then added the script to my page... Now.. does it have to be a PHP file? can it be within a html page? Where does it go? in the <head> section in script tags or the <body> section or what? It's just not working... can someone help? Thanks |
| | |
| | #6 |
| Active Warrior Join Date: Aug 2009
Posts: 56
Thanks: 4
Thanked 2 Times in 2 Posts
|
Anybody have experience with blackhat codebreaker and geolite geoip? I'm trying to implement geoip capability to the bhcb script. Have a problem in the .htaccess rewrite (links.txt -> links.php). It displays the proper links from each country, but still links to the original links.txt instead of using the rewrite links.php country links. I'm using this concept: Remote Insider Affiliate Marketing Forum - View topic - How to Modify BJ Codebreaker Any info or suggestions on this?? |
| Buy Facebook Fans - 100% Guaranteed Real FB fans! unlock iPhone 4s - iPhone Unlocking Solutions for iPhone 4s! unlock iPhone 4 - iPhone Unlocking Solutions for iPhone 4! | |
| | |
| | #7 | |
| Active Warrior Join Date: May 2009
Posts: 59
Thanks: 1
Thanked 0 Times in 0 Posts
| Quote:
| |
| | ||
| | |
| | #8 |
| Warrior Member Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
Power Redirector seems to be a good redirect script, works with different kind of databases
|
| | |
| | #9 |
| <?php echo("Hello"); ?> Join Date: Mar 2011 Location: EU
Posts: 200
Thanks: 3
Thanked 30 Times in 30 Posts
|
First of all: Grats to Pablo! Its always a great experience to solve a problem totaly on its own, isnt it? A few more thoughts: The geomax scripts work fine - however I sometimes encounter little speed problems, but its okay - also I am using the geoip javascript to get visitors info withouth downloading the geoip.dat on my own server and therefor making it a bit slower maybe.... @bestofcuba: keep up the work! i have done almost the same a few years ago when bhcb was just released - so I know for sure it can be done and its a simple task. Unfortunatelly, I think I have lost the files I will try to look for them and pm you if i found them.However, as far as I can remember, there is no need to add .htaccess rules for redirection. You should think about this: adding a link to your geo-redirection script inside links.txt -> once a vistors clicks on it -> redirects to geo script -> check country -> redirect to an offer in his country. hope this helps and i will keep you updated when i find my old files. |
| | |
| | #10 |
| Active Warrior Join Date: May 2011
Posts: 86
Thanks: 3
Thanked 3 Times in 3 Posts
| |
|
Looking for a serious JV partnership. Pm me
| |
| | |
| | #11 | |
| Warrior Member Join Date: Jul 2009
Posts: 27
Thanks: 2
Thanked 0 Times in 0 Posts
| Quote:
| |
| | |
![]() |
|
| Tags |
| based, country, redirect, traffic, visitor |
| Thread Tools | |
| |
![]() |