隐藏http响应头中X-Powered-By输出php版本

在php程序中,默认会在http请求响应头中输出php版本信息。如下:

HTTP/1.1 200 OK
Server: nginx
Date: Sat, 11 Apr 2015 02:18:39 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.4.26文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

为了服务器的安全,可以选择不输出X-Powered-By信息,这样也就不会显示php版本号了。文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

禁止输出X-Powered-By,可以修改php.ini 的expose_php,把默认的On改成Off即可。文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

在php.ini中找到:文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

expose_php = on文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

修改为:文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

expose_php = Off文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

修改完成后重启web服务,后续PHP程序头部就不会再输出类似X-Powered-By: PHP/5.4.26的信息。文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html 文章源自堕落的鱼-https://www.duoluodeyu.com/1276.html

 
    • World
      World 3

      这个不错 :!:

    匿名

    发表评论

    匿名网友
    :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
    确定

    拖动滑块以完成验证