Re: IP based redirection

From: Date: Tue, 05 Feb 2002 04:54:15 +0000
Subject: Re: IP based redirection
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83524@lists.php.net to get a copy of this message
Hi, This could be done by having a conf file through which you could get the IP address of the machine from where the request is come. ie.. <? ///////// This is a seudo //////// *------------------------------- * This is the conf file conf.php *------------------------------- // gets IP of the machine from where the request is come $IP = GetEnv("REMOTE_ADDR"); or // gets IP of the server $IP = GetEnv("SERVER_ADDR"); // the ISP's IP $tamilISP = 192.232.0.232; $hindiISP = 192.232.0.233; $kanadaISP = 192.232.0.234; $telguISP = 192.232.0.235; if($IP == $tamilISP) { $page = "tamil.php"; //or $lang = "tamil"; } elseif($IP == $hindiISP); { $page = "hindi.php"; //or $lang = "hindi"; } elseif($IP == $kanadaISP) { $page = "kanada.php"; //or $lang = "kanada"; } elseif($IP == $teleguISP) { $page = "telegu.php"; //or $lang = "telegu"; } ?> You can include the above conf file in other scripts of yours and you and do a check according to your need, and display pages according to the result of the check. Good luck cheers JFK kishor Nilgiri Networks. On Sat, 2 Feb 2002, PHPbin@dinsol.com wrote: > Could you please help us, to redirect some of our pages to based on IP > address. We have used SmartRedirect program but it is not working on > with some of our ISP's IP address. We are located at India, and like > to have some language specific pages to be displayed to our Indian > user while english language to other world. Thanks, > > Hemant Kumar > DInsol.com > http://www.dinsol.com/ >

« previous php.general (#83524) next »