title: Redirect to random URL using php
body: <p>I have tried using this from <a href="https://stackoverflow.com/a/14281559/2461805">here</a></p>
  
  <pre><code>&lt;?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);
  ?&gt;
  </code></pre>
  
  <p>But every time I open another tab and load <code>index.php</code> I still get <code>http://1.com</code> every time. </p>
  
  <p>How can I solve this problem?</p>
  
  <p>Thanks in advance.</p>