nginx开启网站目录浏览功能

一、开启全站目录浏览功能

编辑nginx.conf, 在http下面添加以下内容:

autoindex on;  # 开启目录文件列表
autoindex_exact_size on;  # 显示出文件的确切大小,单位是bytes
autoindex_localtime on;  # 显示的文件时间为文件的服务器时间
charset utf-8,gbk,gb2312;  # 避免中文乱码

add_header Content-Disposition attachment;  # 文件下载(可以不开启该功能)

二、开启网站部分目录浏览功能

编辑nginx.conf ,在server {} 模块或者 localtion 模块下加入以下内容:

autoindex on;  # 开启目录文件列表
autoindex_exact_size on;  # 显示出文件的确切大小,单位是bytes
autoindex_localtime on;  # 显示的文件时间为文件的服务器时间
charset utf-8,gbk,gb2312;  # 避免中文乱码

 

posted @ 2019-12-19 10:32  远洪  阅读(1775)  评论(0编辑  收藏  举报