dir listing 目录文件列表索引

一般而言,网站应用都有一个入口,比如说:index.php,index.html,app.js等。通过这个路口,以及相应的路由功能,去到网站各个功能版块。
而网站的目录结构,目录里面的文件列表,一般都是对用户规避的。原因有两个:一个是安全,另一个是跟业务无关。

所以一般情况下,我们很难看到目录结构,如果需要做dir listing,需要做一些配置。
就apache而言,首先要启用 httpd-autoindex模块。然后再 httpd.conf --> Directory 配置中,加上 indexes的配置项

<Directory />
    Options FollowSymLinks Indexes
    #AllowOverride None
    AllowOverride All
    Order deny,allow
    allow from all
</Directory>

就nginx而言,需要添加autoindex:on的配置

server {
        listen   80;
        server_name  domain.com www.domain.com;
        access_log  /var/...........................;
        root   /path/to/root;
        location / {
                index  index.php index.html index.htm;
        }
        location /somedir {
               autoindex on;
        }
}

Ref

原文地址:https://www.cnblogs.com/flowerszhong/p/6987267.html