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))]);
    }
}
?>