Reputation:
I have tried using this from here
<?php
$urls = array('http://1.com',"http://2.com","http://3.com"); //specify array of possible URLs
$rand = rand(0,count($urls)-1); //get random number between 0 and array length
$location = $urls[$rand]; //get random item from array
header ('HTTP/1.1 301 Moved Permanently'); //send header
header ('Location: '.$location);
?>
But every time I open another tab and load index.php
I still get http://1.com
every time.
How can I solve this problem?
Thanks in advance.
Upvotes: 1
Views: 2062
Reputation: 6319
It's probably browser caching.
When you send a 301 you are informing the browser that you have permanently moved a web address to the one you are providing, so the browser naturally assumes that you truly mean permanently and he will only use that address in the future without asking the server.
Use a 307: Temporary Redirect
header if you want temporary redirection.
Upvotes: 1