php – 是否有一个很好的替代$_SERVER [‘SERVER_NAME’]?
作者:互联网
我在PHP doc pages上阅读了以下评论:
“Be warned that most contents of the Server-Array (even
$_SERVER[‘SERVER_NAME’]) are provided by the client and can be
manipulated. They can also be used for injections and thus MUST be
checked and treated like any other user input.”
那时我在on StackOverflow saying that $_SERVER[‘SERVER_NAME’] is partly server controlled看到了一个话题.
我可以信任这个值来获取我网站的网址吗?如果我不能真正信任$_SERVER [‘SERVER_NAME’],我该如何获得此值?有哪些可能的替代方案及其利弊?
OBS:Apache,Unix上的PHP 5.3.
解决方法:
您可以通过在Apache配置中启用UseCanonicalName指令来强制执行此变量的安全性,如http://www.apacheref.com/ref/http_core/UseCanonicalName.html所述
标签:apache,php,security,superglobals 来源: https://codeday.me/bug/20190626/1288671.html