$ _ SERVER ['HTTP_HOST'] =一个IP,这不是我的服务器 [英] $_SERVER['HTTP_HOST'] = an ip that's not my server
问题描述
我的PHP脚本有$ _ SERVER ['HTTP_HOST']是等于拥有无关,与我的服务器的IP中的IP。
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
推荐答案
HTTP_HOST
由客户提供,在主持人:
的HTTP请求的一部分。它可以随意改变的,虽然我不明白为什么人会愿意。请参见手册页。
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.
使用 $ _ SERVER ['SERVER_NAME']
来代替。这是通过服务器本身定义
Use $_SERVER['SERVER_NAME']
instead. This is defined by the server itself.
这篇关于$ _ SERVER ['HTTP_HOST'] =一个IP,这不是我的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!