删除 X-Powered-By
如何删除 PHP 中的 X-Powered-By 标头?我在 Apache 服务器上,使用 php 5.21。 我无法在 php 中使用 header_remove 函数,因为 5.21 不支持它。我使用了 Header unset X-Powered-By,它在我的本地计算机上工作,但在我的生产服务器上不起作用。
如果 php 不支持 header_remove() 版本
5.3,有替代方案吗?
How can I remove X-Powered-By header in PHP? I am on an Apache Server and I use php 5.21.
I can't use the header_remove function in php as it's not supported by 5.21. I used Header unset X-Powered-By, it worked on my local machine, but not on my production server.If php doesn't support header_remove() for ver < 5.3, is there an alternative?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我认为这是由 PHP.ini< 中的
expose_php
设置控制的/a>:不存在直接的安全风险,但正如 David C 指出的那样,暴露过时(且可能存在漏洞)的 PHP 版本可能会邀请人们尝试攻击它。
I think that is controlled by the
expose_php
setting in PHP.ini:There is no direct security risk, but as David C notes, exposing an outdated (and possibly vulnerable) version of PHP may be an invitation for people to try and attack it.
https://secure.php.net/manual/en/function.header -删除.php
https://secure.php.net/manual/en/function.header-remove.php
如果您无法禁用 expose_php 指令< /a> 要使 PHP 的谈话静音(需要访问 php.ini),您可以使用 Apache 的
Header
指令 删除标头字段:If you cannot disable the expose_php directive to mute PHP’s talkativeness (requires access to the php.ini), you could use Apache’s
Header
directive to remove the header field:如果您有权访问 php.ini,请设置
expose_php = Off
。If you have an access to php.ini, set
expose_php = Off
.尝试在发送标头之前添加 header() 调用,例如:
无论 php.ini 中的 hide_php 设置如何
Try adding a header() call before sending headers, like:
regardless of the expose_php setting in php.ini
如果您使用 FastCGI 尝试:
If you use FastCGI try:
要隐藏 X-Powered-By: PHP/7.xx ,如果您使用共享主机、VPS、云服务器,则在 .htaccess 文件中添加以下代码
适用于:
Wordpress、Codeigniter、Laravel、Php
To hide X-Powered-By: PHP/7.x.x , if you are using Share Hosting, VPS, Cloud Server then add the following code in .htaccess file
Work well for:
Wordpress, Codeigniter, Laravel, Php
这个解决方案对我有用:)
请在脚本中添加以下行并检查。
可能不需要 Ngnix / Apache 等级别设置。
This solution worked for me :)
Please add below line in the script and check.
Ngnix / Apache etc level settings might not be required.