我已经从Apache切换到nginx了,我发现一个方便的东西是能够把一个'index.html'文件放在一个目录中,并且被提供,但是如果没有这样的文件存在,Apache会生成一个目录列表。 我已经能够得到nginx做目录列表,但它忽略了index.html文件。 有没有人能够实现这一行为?
你想要的状态是Nginx的autoindex的正常行为:
通常,当
ngx_http_index_module模块找不到索引文件时,ngx_http_index_module请求传递到ngx_http_autoindex_module模块。语法:
autoindex on | off;autoindex on | off;默认:autoindex off;上下文:http,服务器,位置启用或禁用目录列表输出。
索引文件的默认值是index index.html; 。
你可能已经configuration了别的东西在你的configuration中,你没有提供的地方。 如果你有:
location / { index index.html; autoindex on; }