hwo to redirect users depending on their country in php (with maxmind geoip) ?

iglow's Avatar, Join Date: Dec 2009
Go4Expert Member
Exactly as mentioned i have trouble wit hthat. I want to use the maxmind geoip base in php so that when user comes to my aaa.com then it checks if hes from .be .fr .ca and puts him on aaa.com/1.htm, if from .uk .au .us to aaa.com/2.htm anf if from other place tio aaa.com/3.htm [or .php doesnt matter here]
Im sure its simple but somehow i cant code it. Would love the help of some expert
venami's Avatar, Join Date: Dec 2008
Ambitious contributor
You can use the Geo IP Location extension of PHP.

Please see the link below:

http://php.net/manual/en/book.geoip.php
iglow's Avatar, Join Date: Dec 2009
Go4Expert Member
im reading that but looks complex to me, im not so good with php [i can edit simple parts but mainly i need more 'step by step' info.
cant i just upload the files of geoip and put 2-3 pages of php code that will read them and make use of them? this looks a bit too complex with those shell commands

thanx
venami's Avatar, Join Date: Dec 2008
Ambitious contributor
I have never heard of Geo IP extension of PHP earlier. I came to know about it only after your question. I also have to go through it to know more about GeoIP.
iglow's Avatar, Join Date: Dec 2009
Go4Expert Member
im sure it can be done in php just by uploading all the files [not even importing to mysql] and using 1-2 .php files - ive seen such thing, but i have no idea how to do it and my knowledge of php doesnt allow me it seems

happy i
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by venami View Post
I have never heard of Geo IP extension of PHP earlier. I came to know about it only after your question. I also have to go through it to know more about GeoIP.
Search the Articles and you would see it here as well.
iglow's Avatar, Join Date: Dec 2009
Go4Expert Member
Quote:
Originally Posted by shabbir View Post
Search the Articles and you would see it here as well.
shabbir ive searched and i found some similar stuff but not exactly o nthe topic. i found only blocking by country in .htaccess with using php. and thats totally not what i want to do

@ venami and i couldnt edit the post abouve but i wanted to say im happy i shown u something new with my question
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Did you see Getting Visitor's Country with PHP using Geo IP
iglow's Avatar, Join Date: Dec 2009
Go4Expert Member
Quote:
Originally Posted by shabbir View Post
hey yes ive seen but the modification seems not that obvious,
have a look:

Code:
 
<?php // include functions include("geoip.inc"); // read GeoIP database $handle = geoip_open("GeoIP.dat", GEOIP_STANDARD); // map IP to country echo "IP address 62.149.130.132 located in " . geoip_country_name_by_addr($handle, "62.149.130.132") . " (country code " . geoip_country_code_by_addr($handle, "62.149.130.132") . ")"; // close database handler geoip_close($handle); // print compulsory license notice echo "<p> -- This product includes GeoIP data created by MaxMind, available from http://maxmind.com/ --"; ?>


this code is suspossed to read the country code by using function include(). but now im not sure how to make working variabilities to redirect people from 9 countries [3 groups each for 3 countries] to 3 different adresses also not sure what kind iof redirect should be used.
if somebody could have a look at this i would be pleased
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Redirect should be plan header if possible or else could be anything you like but the 3 countries of 3 group looks very simple. Whats the issue there.