im struggling to find a way to redirect a wordpress page to a random predefined list of url’s.
Each URL is a sub domain of the original domain, so:
page1.homepage.com, page2.homepage.com, page3.homepage.com
I know this code should appear before the doctype which i’ve done.
Now for some reason i cant get it to work! Any help would be much appreciated!
Here is my code:
$urls = array('http://1.home.com','http://2.home.com','http://3.home.com');
$random_value = array_rand($urls);
$random_link = $urls[$random_value];
("location: $random_link")
In wordpress there is an built in function to do that wp_redirect,
use it like this,
Reffer for more information wp redirect