Home >Backend Development >PHP Tutorial >hide php script extension

hide php script extension

伊谢尔伦
伊谢尔伦Original
2016-11-22 10:38:471449browse

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, which can make it more difficult for attackers to discover system weaknesses. Setting expose_php = off in the php.ini file reduces the amount of useful information they can obtain.

Another strategy is to let the web server parse different extensions using PHP. Whether through .htaccess files or Apache configuration files, you can set file extensions that can mislead attackers:

Example #1 Hide PHP as another language

# 使PHP看上去像其它的编程语言
AddType application/x-httpd-php .asp .py .pl

Or hide it completely:

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, which will add some burden to the server:

Example #3 Use HTML to make PHP files 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.


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