My company uses a piece of PHP-based software that depends on $_SERVER['SERVER_NAME']
to construct a URL. It runs on PHP 5.2 under Windows Server 2003 or 2008 with IIS6 or IIS7 through FastCGI.
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 http://app.foo.com/myscript.php, $_SERVER['SERVER_NAME']
is 'app.foo.com', if you call it with http://192.168.1.22/myscript.php
, $_SERVER['SERVER_NAME']
is '192.168.1.22', etc.
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.
Now that this issue has come up, we're working on eliminating the use of $_SERVER['SERVER_NAME']
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 $_SERVER['SERVER_NAME']
always contains the host from the requesting URL, is there at least some way to configure it so that $_SERVER['SERVER_NAME']
will contain a particular desired FQDN ('app.foo.com' instead of 'myserver')?
EDIT: Added a bounty as I am very interested in receiving an answer to this question.