$_SERVER[“SERVER_NAME”] not showing www.example.com

喜欢而已 提交于 2019-12-24 22:17:04

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1481737/serverserver-name-not-showing-www-example-com

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