网站配置文件是否应隐藏?禁止外部访问,如.htaccess保护
防护方案对比
安全增强建议
服务器类型 | 配置方法 | 测试命令 |
---|---|---|
Apache | .htaccess 添加:<br><Files *.php> <br>Deny from all <br></Files> |
curl -I http://example.com/config.php |
Nginx | 在server块添加:<br>`location ~* /(config | database).php { deny all; }` |
通用方案 | 将配置文件移到web目录外 | 需修改include路径 |
- 设置文件权限为640:
chmod 640 config.php
- 配置WAF规则拦截/config.*路径访问
更新时间:2025-06-22 12:12:07
下一篇:无法打开此文件出错了