$servers = array('s1','s2','s3'); // list of subdomains $ip = $_SERVER['HTTP_CF_CONNECTING_IP']?:$_SERVER['REMOTE_ADDR']; $i = ((int)str_replace('.','',$ip))%count($servers); $server = $servers[$i]; $server_current = array_shift((explode('.',$_SERVER['HTTP_HOST']))); if ($server_current!=$server) /**/echo 'Wrong server!'; // replace this by a redirect to the correct location