模块 ngx_http_index_module
| 配置示例 指令 index |
ngx_http_index_module 模块处理以斜杠字符(‘/’)结尾的请求。此类请求也可以由 ngx_http_autoindex_module 和 ngx_http_random_index_module 模块处理。
配置示例
location / {
index index.$geo.html index.html;
}
指令
| 语法 |
index |
|---|---|
| 默认值 |
index index.html; |
| 上下文 |
http, server, location |
定义将用作索引的文件。file 名称可以包含变量。文件按指定顺序检查。列表中的最后一个元素可以是带有绝对路径的文件。示例
index index.$geo.html index.0.html /index.html;
应该注意的是,使用索引文件会导致内部重定向,并且请求可以在不同的 location 中处理。例如,对于以下配置
location = / {
index index.html;
}
location / {
...
}
一个 “/” 请求实际上将在第二个 location 中作为 “/index.html” 处理。