nginx之root、alias、index、autoindex

server {
    listen 80;
    default_type text/plain;
    server_name fpm.haosheng.vip;

    # Syntax:    root path;
    # Default:root html;
    # Context:    http, server, location, if in location

    # Syntax: index file ...;
    # Default: index index.html;
    # Context: http, server, location

    location /root {
        root html;
        # 访问路径 http://fpm.haosheng.vip/root/a
        # 最终访问 $dcument_root/root/a
    }

    location /alias {
        alias html/; # alias目录必须要以 / 结尾且alias只能在location中使用
        # 访问路径 http://fpm.haosheng.vip/alias/a/
        # 最终访问 $dcument_root/a/index.html 注意:这里去找了index.html index指令默认为index.html
    }

    location / {
        echo 111;
    }

    location /docs {
        root html;
        autoindex on; # 开放文件访问 默认关闭
        autoindex_exact_size on; #  显示文件大小 Default: autoindex_exact_size on;
        autoindex_format html; # Default:  autoindex_format html; 展现格式
        autoindex_localtime on;
    }
}
原文地址:https://www.cnblogs.com/sanshuiqing/p/14555411.html