faqts : Computers : Programming : Languages : PHP : Common Problems : Visitor Information

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 4 people (50%) answered Yes
Recently 2 of 4 people (50%) answered Yes

Entry

how can I redirect a user with wildcards like 213.* or hostname like *.isp.net

Jan 19th, 2002 20:46
Lisa Fehr, joachim molund, http://www.php.net/manual/en/function.ereg.php


<?
$Redirect_Page="http://test.com";
if(ereg("^213.|isp.net$","$REMOTE_ADDR||$REMOTE_HOST")){header("location
: $Redirect_Page");}
?>
Use ereg to detect the IP($REMOTE_ADDR) or(||) the users 
hostname($REMOTE_HOST)
"^213.|isp.net$" <- will detect if either the ip or hostname starts(^) 
or(|) ends($) with what ever you define.
hmm, wish I could remember where at php.net I recall this information 
from: 
"^The": matches any string that starts with "The"; 
"of despair$": matches a string that ends in the substring "of despair";