Home  >  Article  >  Backend Development  >  How to hide header version output (X-Powered-By) information in PHP

How to hide header version output (X-Powered-By) information in PHP

WBOY
WBOYOriginal
2016-07-25 08:57:062626browse
This article introduces the method of hiding the version of the PHP header and outputting x-powered-by. Friends in need can refer to it.

In the php program, header information will be output by default: (Status-Line) HTTP/1.1 200 OK Date Wed, 23 Feb 2011 02:30:46 GMT Server Apache/2.2.13 (Win32) X-Powered-By: PHP/5.2.3 Content-Length 30 Keep-Alive timeout=5, max=100 Connection Keep-Alive Content-Type text/html

To avoid outputting the above version information, you can modify expose_php in php.ini and change the default On to Off.

Hide and disguise the Apache version. To hide the PHP header version, you can refer to the following method.

1, add in Apache’s http.conf: ServerSignature Off ServerTokens Prod

Among them, ServerSignature Off tells Apache not to display server version information on error pages (HTTP Status 404 and the like), but this option does not affect pages that can be accessed normally (HTTP Status 200 and the like). There is still server version information in the Server Header when accessing the web page normally.

ServerTokens Prod tells Apache to only return Apache in the server header information (Server Header), and does not return the server operating system and Apache version information.

2, Hide php header version php.ini expose_php = Off Hide messages similar to X-Powered-By: PHP/5.2.4 sent by the PHP program header

Set in php.ini file: expose_php = Off You can avoid outputting version information like: X-Powered-By: PHP/5.2.4.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn