您的位置 首页 php

linux系统下禁止上传目录执行php脚本?

可以通过修改nginx.conf配置文件实现。

方法如下:

禁止单目录:

 location ~* ^/attachments/.*.(php|php5)$ {
deny all;
}
  

禁止多目录:

 location ~* ^/(attachments|upload)/.*.(php|php5)$ {
deny all;
}
  

注意:

1、以上的配置文件代码需要放到 location ~ .php{…}上面,如果放到下面是无效的。

2、attachments需要写相对路径,不能写绝对路径

3、不要忘记重启nginx

 service nginx restart
  

文章来源:智云一二三科技

文章标题:linux系统下禁止上传目录执行php脚本?

文章地址:https://www.zhihuclub.com/150594.shtml

关于作者: 智云科技

热门文章

评论已关闭

1条评论

  1. Hmm is anyone else experiencing problems with tthe pictures on this
    blog loading? I’m trying to figure out if itss a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

    my web page ::

网站地图