可以通过修改nginx.conf配置文件实现。
方法如下:
禁止单目录:
location ~* ^/attachments/.*.(php|php5)$ { deny all; }
(视频教程推荐:linux视频教程)
禁止多目录:
立即学习“PHP免费学习笔记(深入)”;
location ~* ^/(attachments|upload)/.*.(php|php5)$ { deny all; }
注意:
1、以上的配置文件代码需要放到 location ~ .php{...}上面,如果放到下面是无效的。
2、attachments需要写相对路径,不能写绝对路径
3、不要忘记重启nginx
service nginx restart
推荐教程:linux教程
以上就是linux下禁止上传目录执行php脚本的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号