$md5ip = substr(md5($_SERVER{'REMOTE_ADDR'}), 0, 1);
if ($md5ip <= '7') {
header('Location: http://site2.ru');
exit;
}
$prc=20;
$ip=gethostbyname($_SERVER['REMOTE_ADDR']);
$p=explode('.',$ip);
$p=$p[3]*100/254; //exclude multicast: 255
if($p<=$prc) {
//header('Location: http://site1.ru');exit;
echo $ip.' in range: 0-'.$prc.'% ('.$p.')';
}
else {
//header('Location: http://site2.ru');exit;
echo $ip.' in range: >'.$prc.'-100% ('.$p.')';
}