Forum Moderators: phranque
HTTP_HOST is the domain name, as expected, but SERVER_NAME is a subdomain on a parent domain.
SERVER_NAME = subdomain.domain1.com
HTTP_HOST = domain2.com
Both addresses are prefectly valid, I'm just trying to figure out why the difference.
Tom
Again, I have
domain1.com
subdomain.domain1.com
domain2.org (which maps to subdomain.domain.com)
In PHP, I use either SERVER_NAME or HTTP_HOST to build absolute URIs.
When I visit
domain2.org/page
I would expect that server_name would be subdomain.domain1.com, since that's what it's set as in httpd. I would expect http_host to be domain2.org, since that's what it is in the request. And in fact, that's how it works.
Here's the part I don't get. When I visit
subdomain.domain1.com/page
I would HTTP_HOST to now be changed to subdomain.domain1.com, but in fact, it's still set to domain2.org.
So the HTTP_HOST value is coming from somewhere other than the http request. I'm assuming that there's some rewriting flag that transforms it in this case or something.