Page 1 of 1

Difference b/w SERVER_NAME and HTTP_HOST

Posted: Tue Jun 07, 2005 11:07 am
by anjanesh
What difference can there be between $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] ?

Both are always rerturning the same values. Which is the one to determine subdomains ? Both are showing the correct sub-domain.

Thanks

Posted: Tue Jun 07, 2005 12:05 pm
by timvw
'SERVER_NAME'
The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

'HTTP_HOST'
Contents of the Host: header from the current request, if there is one.



My guess (not sure, should give it a try) is that if you have for example
<VirtualHost 127.0.0.1>
ServerName test
Alias tester
</Virtualhost>

And you surf to http://tester

$_SERVER['SERVER_NAME'] => test
$_SERVER['HTTP_HOST'] => tester