nginx设置列出文件或目录功能
在nginx的配置文件的http段或server段添加:
autoindex on;//自动显示目录 autoindex_exact_size off;//人性化方式显示文件大小否则以byte显示 autoindex_localtime on;//按服务器时间显示,否则以gmt时间显示
查看效果

只开启单独目录
示例:只开启dir目录的文件列出功能
location ~ /dir { autoindex on; autoindex_exact_size off; autoindex_localtime on charset utf-8,gbk; #防止中文乱码 }
server {
listen 80;
server_name mirrors.cnbugs.com;
root /data/;
index index.html;
location /ubuntu/ {
alias /data/ubuntu/;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。