title: PHP $_SERVER['SERVER_NAME'] returns machine name in IIS6
body: <p>My company uses a piece of PHP-based software that depends on <code>$_SERVER['SERVER_NAME']</code> to construct a URL. It runs on PHP 5.2 under Windows Server 2003 or 2008 with IIS6 or IIS7 through FastCGI.</p>
  
  <p>This works "correctly" (or, at least, how we expect it to work) on every IIS system we've ever installed it on. In other words, on the same server, if you call it with <a href="http://app.foo.com/myscript.php" rel="nofollow">http://app.foo.com/myscript.php</a>, <code>$_SERVER['SERVER_NAME']</code> is 'app.foo.com', if you call it with <code>http://192.168.1.22/myscript.php</code>, <code>$_SERVER['SERVER_NAME']</code> is '192.168.1.22', etc.</p>
  
  <p>Today, for the first time ever, we installed it on a server (Windows Server 2003 with IIS6) that acts differently. No matter what URL we use to load the script, $_SERVER['SERVER_NAME'] is 'myserver' (the machine name of the server), which is causing problems.</p>
  
  <p>Now that this issue has come up, we're working on eliminating the use of <code>$_SERVER['SERVER_NAME']</code> in future releases of the software ... but is there any configuration I can perform (in IIS6, php.ini, ... ?) on this server to fix this in the meantime? If we can't change it so that <code>$_SERVER['SERVER_NAME']</code> always contains the host from the requesting URL, is there at least some way to configure it so that <code>$_SERVER['SERVER_NAME']</code> will contain a particular desired FQDN ('app.foo.com' instead of 'myserver')?</p>
  
  <p>EDIT: Added a bounty as I am very interested in receiving an answer to this question.</p>