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
Difference b/w SERVER_NAME and HTTP_HOST
Moderator: General Moderators
'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
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