$_SERVER[“SERVER_NAME”] 未显示 www.example.com
为什么 $_SERVER["SERVER_NAME"]
不回显 www.example.com
中的 www
,但当我从像 test.example.com
这样的子域?
Why does $_SERVER["SERVER_NAME"]
not echo the www
in www.example.com
but it does work when I echo it from a sub domain like test.example.com
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道为什么它不包含预期值。但尝试
$_SERVER['HTTP_HOST']
< /a> 相反,它包含客户端在 中提供的值HTTP 标头字段Host。但请参阅Chris Shiftlett 的SERVER_NAME
出于安全考虑,与HTTP_HOST
相比。I don’t know why it doesn’t contain the expected value. But try
$_SERVER['HTTP_HOST']
instead, that contains the value provided by the client in the HTTP header field Host. But see Chris Shiftlett’sSERVER_NAME
VersusHTTP_HOST
for security considerations.