$_SERVER['HTTP_HOST'] = an ip that's n

2019-05-11 17:48发布

my php script has $_SERVER['HTTP_HOST'] is equals to an ip that has nothing to do with my server's ip.

Someone got an easy explanation?

(I was thinking some bot is sending a completly wrong Host header, but i don't think it can connect to a server with a wrong host header =/ )

thx

2条回答
Viruses.
2楼-- · 2019-05-11 18:21

The Host header has absolutely nothing to do with connecting to the web server. It is used by the web server, once connected, to route the HTTP conversation to a particular virtual host. It may be that the virtual host your script is in is the default virtual host, in which case the HTTP conversation will be routed to it provided it doesn't match any other virtual hosts.

查看更多
叼着烟拽天下
3楼-- · 2019-05-11 18:28

HTTP_HOST is provided by the client, in the Host: part of the HTTP request. It can be changed arbitrarily, though I can't see why one would want to. See the manual page.

Use $_SERVER['SERVER_NAME'] instead. This is defined by the server itself.

查看更多
登录 后发表回答