SELECT url FROM links ORDER BY RAND() LIMIT 1 $urls = array( ... ); shuffle($urls); // redirect to $url[0]; header('Location: ' . $urls[0]); exit();