四条预防PHP源代码泄漏的方法:
1)使用mod_security过滤输出严防泄漏 Use mod_security to filter output and prevent leakage (例如)
PHP代码
SecFilterOutput On
SecFilterSelective OUTPUT “<?php ” log,deny
2)不要将关键敏感代码放到根目录中 Code should live outside of the web root (例如)
PHP代码
index.php:
include(‘../realroot/index.php’);
?>
3)更改默认的文件类型 Change the default file type (例如对http.conf做如下修改)
PHP代码
httpd.conf:
DefaultType application/x-httpd-php
4)绝对禁止访问根目录 Deny all outside of the webroot (假设你的根目录是 ‘www’ ,例如)
PHP代码
http.conf: (or .htaccess)
Order Deny,Allow
Deny from all
Options None
AllowOverride None
Order Allow,Deny
Allow from all
赞过:
赞 正在加载……
相关