加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 是否有一个很好的替代$_SERVER [‘SERVER_NAME’]?

发布时间:2020-12-13 17:13:09 所属栏目:PHP教程 来源:网络整理
导读:我在 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 t
我在 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所述

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读