$_SERVER['HTTP_HOST'] = an ip that's not my server

丶灬走出姿态 提交于 2019-12-10 10:08:36

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4696684/serverhttp-host-an-ip-thats-not-my-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!