title: Redirect visitor based on referral URL
body: <p>I want to redirect visitors to one page on my website if they have come from a certain URL and another if they don't. </p>
  
  <pre><code>&lt;?
  $referer = $_SERVER['HTTP_REFERER'];
  if ( $referer != "http://URL1" ) {
    header('Location: page1');
    exit;
   } else {
    header('Location: page2');
   }
  ?&gt;
  </code></pre>
  
  <p>Whatever referrer I come to the page on it goes to page 1 and never to page 2. I have used this code in a index.php file so its the first page the visitor is directed too.</p>