title: PHP Permanent Redirection
body: <p>I'm having a strange issue with a permanent redirection in PHP. </p>
  
  <p>Here's the code I'm using:</p>
  
  <pre><code>if ($_SERVER['HTTP_HOST'] != 'www.mydomain.ca')   
  {
      header("HTTP/1.1 301 Moved Permanently"); 
      $loc = "http://www.mydomain.ca".$_SERVER['SCRIPT_NAME'];
      header("Location: ".$loc);
      exit;
  }
  </code></pre>
  
  <p>So, the home page, referenced either by www.myolddomain.ca or www.myolddomain.ca/index.php both work but every other page on the site fails to redirect. I've spent a couple of hours looking at this from all the angles I know and can't fathom it. Does anyone have any idea what the issue could be?</p>
  
  <p>As a note, I've tried this without the 301 header too and get the same issue.</p>