nginx 下禁止访问某个目录(文件夹)或文件

2019-12-29T03:29:40

在nginx下要禁止访问某个目录或文件

要配置nginx.conf

禁止访问目录

location ^~/path {

    deny all;

}

注意path后要是没有"/"表示禁止访问所有以path为开头的文件和目录,加上"/"表示禁止访问目录/path/

禁止访问文件

location ~* /.html {

    deny all;

}

表示禁止访问扩展名为html的文件

 

via.https://my.oschina.net/u/1036767/blog/209743

参考:http://www.nginx.cn/125.html

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »