[WEB4LIB] IP Address Detection
William Barnes
wbarnes at husky.bloomu.edu
Fri Nov 9 08:01:08 EST 2001
We do this in PHP, works like a champ!
Here is a code snippet:
<?php
// Bill's handy-dandy URL redirection based on IP.
// Since I'm using HEADER location redirection, I can't used any 'echos' or other output.
// written: 07 / 05 / 01
$ip = getenv ("REMOTE_ADDR");
$iparray = explode(".", $ip);
// Check for BloomU IPs... First two octects are 184.137
if ( ($iparray[0] == "148") and ($iparray[1] == "137")) {
header("Location: pages/dbsubj.html");
exit;
} else {
header("Location: pages/dbremote.html");
exit;
}
?>
Thanks!
--Bill
*******************************************
* Bill Barnes, RHCE, CCNA, CNA, MCP, A+
* Library Network Administrator
* Harvey A. Andruss Library
* Bloomsburg University
* ph: 570-389-2813
* e-mail: wbarnes at bloomu.edu
*******************************************
>>> "Donald Barclay" <dbarclay at library.tmc.edu> 11/08/01 04:45PM >>>
Anyone know of a quick, cheap, and good way to detect a site visitor's IP
address and, based on this, direct them to a particular page on your site?
Donald A. Barclay
Assistant Director for Systems and Informatics
Houston Academy of Medicine--
Texas Medical Center Library
dbarclay at library.tmc.edu <mailto:dbarclay at library.tmc.edu>
713.799.7120
always the beautiful answer
who asks a more beautiful question
--e.e. cummings
More information about the Web4lib
mailing list