According to RFC 2616, which defines HTTP/1.1, the Host:
header is mandatory.
A client MUST include a Host header field in all HTTP/1.1 request messages .
But the PHP manual implies that it could be empty:
'HTTP_HOST': Contents of the Host: header from the current request, if there is one.
In which situations could this header, and thus $_SERVER['HTTP_HOST']
, be empty? Could my application depend on its being there?
Host:
header is still 'mandatory' as per HTTPbis, but that doesn't mean it will always be present. Apache handles its absence gracefully (albeit it won't reach any configured vhost). – CommunicantHost:
header? – Justinejustinian