Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like
Redirecting Specific IP's to Other Websites Using PHP
Someone had requested a script that would redirect a list of ip’s to a random list of sites.
Here’s the snippet I came up with:
<?
// list of ip's you wish to redirect
$ips = array('127.0.0.1');
// Sites you wish to redirect to
$sites = array('http://yahoo.com/','http://www.aol.com');
foreach($ips as $ip) {
if ($ip==GetHostByName($REMOTE_ADDR)) {
header('Location: ' . $sites[rand(0,count($sites))]);
}
}
?>
| Print article | This entry was posted by Tyler Mulligan on January 20, 2008 at 4:50 pm, and is filed under PHP, Programming. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |