Home >Backend Development >PHP Problem >How to hide php code
Method to hide php code: You can choose to use an unknown extension as the extension of php to make php look like an unknown file type, such as [AddType application/x-httpd-php .bop .foo. 133t].
# Generally speaking, improving security through hidden means is considered to be of little effect. But in some cases, adding as much security as possible is worth it.
Some simple methods can help hide PHP, and doing so can make it more difficult for attackers to discover system weaknesses. Setting expose_php = off in the php.ini file reduces the useful information they can obtain.
(Recommended tutorial: php video tutorial)
Another strategy is to let the web server use PHP to parse different extensions. Whether through .htaccess files or Apache configuration files, it is possible to set file extensions that can mislead attackers.
Example 1: Hide PHP as another language
# 使PHP看上去像其它的编程语言 AddType application/x-httpd-php .asp .py .pl
Or simply hide it completely:
(Related learning recommendations:java video tutorial )
Example 2: Use an unknown extension as the PHP extension
# 使 PHP 看上去像未知的文件类型 AddType application/x-httpd-php .bop .foo .133t
or hide it as an HTML page, so that all HTML files will pass through the PHP engine and will be Add some burden to the server:
Example 3: Use HTML to make PHP file suffix
# 使 PHP 代码看上去像 HTML 页面 AddType application/x-httpd-php .htm .html
For this method to take effect, the extension of the PHP file must be changed to the above extension . This improves security through concealment, although defense capabilities are low and have some drawbacks.
Related recommendations: php training
The above is the detailed content of How to hide php code. For more information, please follow other related articles on the PHP Chinese website!