I'm using Apache/2.4.10 (Win32) and I have a question about the relation between SERVER_NAME
and HTTP_HOST
.
I have noticed a strange(at least I think) behavior of apache, inside my httpd.conf
I have:
ServerName example.com:80
Now as I tested via PHP
server variables which are taken from apache.
From php(the link above):
If the script is running on a virtual host, this will be the value defined for that virtual host.
I'm not using any virtual hosts.
SERVER_NAME
overridden by HTTP_HOST
, for example if I will access the website via m.example.com
the SERVER_NAME
is overriden by the HTTP_HOST
and the both be equal to the same value, now in spite it has been tested I wanted to know:
- Does apache using any virtual host without me knowing about it, here is my httpd.conf file?
- Is it
PHP
or apache behavior? - Is it done automatically(the override) by
PHP
or Apache(at this point I don't know who's guilty)?
Edit:
- The override is done by apache, I've tested using
.htaccess
file, the result is that even before the variables delivered toPHP
the override is done.
So the override is done by apache, the only question remain is what are the conditions for such override and more important is there a way to get or a variable that provide the ServerName
value from the httpd.conf
?