title: PHP Redirect problem with subdomain
body: <p>I'm using PHP to redirect a page back to the previous page with the following:</p>
  
  <pre><code>header("Location: {$_SERVER['HTTP_REFERER']}");
  </code></pre>
  
  <p>This set of pages will only be used by internal users, so I'm not terribly concerned about the fact that the referer will not always be available.</p>
  
  <p>The problem I'm running in to is that if the referer looks like <code>http://subdomain.domain.com/test.php?id=13</code>, the redirect ends up going to <code>http://subdomain.domain.com/.domain.com/test.php?id=13</code>.  Notice the additional <code>.domain.com/</code> in the url.</p>
  
  <p>I've tested by hardcoding the value, and it causes the problem as well.  <code>phpMyAdmin</code> seems to suffer the same issue, but only on this particular server.</p>
  
  <p>If this is not an SO question, please move accordingly.</p>
  
  <p><strong>EDIT</strong>: per @yaggo</p>
  
  <p>test.php contains only <code>header("Location: http://subdomain.domain.com/test2.php");</code></p>
  
  <pre><code>curl --head --referer 'http://subdomain.domain.com/' 'http://subdomain.domain.com/test.php'
  
  HTTP/1.1 302 Found
  Server: nginx/0.7.64
  Date: Fri, 02 Apr 2010 17:21:45 GMT
  Content-Type: text/html; charset=UTF-8
  Connection: keep-alive
  X-Powered-By: PHP/5.2.12-pl0-gentoo
  Location: .domain.com/test2.php
  </code></pre>