$ _SERVER [“SERVER_NAME”]不显示www.example.com [英] $_SERVER["SERVER_NAME"] not showing www.example.com
本文介绍了$ _SERVER [“SERVER_NAME”]不显示www.example.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么 $ _ SERVER [SERVER_NAME]
不回覆 www中的
,但是当我从一个子域(如 www
.example.com 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
?
推荐答案
我不知道为什么它不包含预期的值。但请尝试 $ _ SERVER ['HTTP_HOST']
,它包含客户端在 HTTP头域主机 。但请参阅 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’s SERVER_NAME
Versus HTTP_HOST
for security considerations.
这篇关于$ _SERVER [“SERVER_NAME”]不显示www.example.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文