Warning: include_once(/www/wwwroot/huison.cn/head.php): failed to open stream: Permission denied in /www/wwwroot/huison.cn/show.php on line 48

Warning: include_once(): Failed opening 'head.php' for inclusion (include_path='.:/www/server/php/56/lib/php') in /www/wwwroot/huison.cn/show.php on line 48

Warning: include_once(/www/wwwroot/huison.cn/banner.php): failed to open stream: Permission denied in /www/wwwroot/huison.cn/show.php on line 53

Warning: include_once(): Failed opening 'banner.php' for inclusion (include_path='.:/www/server/php/56/lib/php') in /www/wwwroot/huison.cn/show.php on line 53

指定文件夹内禁止访问PHP文件


大多数的网站主页被修改,都是因为网站存在上传漏洞 ,导致黑客上传了网页木马。

现在分享一个比较简单粗暴的方式来解决此问题。

解决办法:在可上传文件的目录下禁止解析PHP,为了避免上传的PHP文件有木马,所以禁止该目录下面的访问解析PHP。一般可写目录、静态文件存放的目录内是不允许存放PHP。

前提是您的空间支持.htaccess,也就是伪静态。

在上传文件的目录里面新建.htaccess文件,输入以下代码,并保存。

<FilesMatch \.(?i:php)(.*)$>
    Order Allow,Deny
    Deny from all
</FilesMatch>

上传到指定目录后。测试访问test.php、test.php.jpg均提示如下:


Forbidden

You don't have permission to access /upload/test.php on this server.

完美!

最后,还是建议大家完善上传代码,从源头解决问题!

其它相关文章:

Warning: include_once(/www/wwwroot/huison.cn/foot.php): failed to open stream: Permission denied in /www/wwwroot/huison.cn/show.php on line 126

Warning: include_once(): Failed opening 'foot.php' for inclusion (include_path='.:/www/server/php/56/lib/php') in /www/wwwroot/huison.cn/show.php on line 126