If you need randomly redirect your traffic to a variety of different URLs, use the following code. This code loads the URLs from an txt file called sites.txt (you can name this whatever you want as long as you change the name in the script below), it then picks one of the URLs at random and redirects the user to that page.

You can save this code in it's own .php file, or add this code to the top of an existing page.

// Load list of sites to rotate
$sites = array_map("trim", file("sites.txt"));

// Choose a site to show
$redirect = $sites[array_rand($sites)];

// Redirect the user
header("Location:$redirect"); die();


The sites.txt (or whatever name you choose) must be in the same directory as the redirection code above.  The URLs in the file should include the http:// and be listed one per line.



If you just want to download the above code and an example sites.txt click here