Help - Search - Members - Calendar
Full Version: Scripts to redirect on geo ip maxmind
The Planet Forums > Security > General Security
instantnet
Maxmind offers a free geo ip database.

I am looking for some simple htacesss redirect scripts.

Basically all user A from usa get one folder and user B from the rest of the world get another folder

Then if someone from group B tried to access folder B they get redirected back to their designated folder.

I think the maxmind database is a bit overkil for this.

Ideas?

Thanks
mikelbeck
I've done this sort of thing for displaying ads on some of my sites... YPN ads are displayed for US visitors, Adsense ads are displayed for all others.

I pulled down a data from ip2nation.com and check the user's IP address against it, if it comes up with "us" they get the YPN ads. I did it in PHP, though, not .htaccess:

CODE
 $sql = 'SELECT country FROM ip2nation WHERE ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") ORDER BY ip DESC LIMIT 0,1';



    list($country) = mysql_fetch_row(mysql_query($sql));



    switch ($country)

 {

 case 'us': // United States

                            // show YPN ad

                         break;



                        default: // everywhere else

                           // show Adsense ad

                        break;

 }


You could probably do the same sort of thing with the maxmind database.

I don't know if this helps you or not...
alamak
You can sample codes from IP2Location Web site.

http://www.ip2location.com/articles.aspx
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.