autoindex on;
就可以了。
autoindex_exact_size on;
# 默认为 on,以 bytes 为单位显示文件大小;
# 切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB。
autoindex_localtime on;
# 默认为 off,以 GMT 时间作为显示的文件时间;
# 切换为 on 后,以服务器的文件时间作为显示的文件时间。
location /download {
# ... 其它同上
charset utf-8,gbk; # 两个字符集间不要加空格
}
location /download {
# ... 其它同上
auth_basic "Enter your name and password";
auth_basic_user_file /var/www/html/.htpasswd;
}
# 创建一个全新的文件,会清除文件里的全部用户 $ htpasswd -c /var/www/html/.htpasswd user1 # 添加一个用户,如果用户已存在,则修改密码 $ htpasswd -b /var/www/html/.htpasswd user2 password # 删除一个用户 $ htpasswd -D /var/www/html/.htpasswd user2