Appearance
模块 ngx_http_index_module
ngx_http_index_module模块处理以斜杠字符('/')结尾的请求。ngx_http_autoindex_module 和 ngx_http_random_index_module模块也可以处理此类请求。
示例
位于nginx.conf配置文件:
location / {
index index.$geo.html index.html;
}指令
txt
Syntax: index file ...;
Default: index index.html;
Context: http, server, location定义将用作索引的文件。文件名file可以包含变量。文件将按指定顺序进行检查。列表的最后一个元素可以是具有绝对路径的文件。例如:
txt
index index.$geo.html index.0.html /index.html;需要注意的是,使用索引文件会导致内部重定向,请求可能会在不同的位置进行处理。例如,使用以下配置:
txt
location = / {
index index.html;
}
location / {
...
}第二个位置的/请求实际上定向到/index.html。