nginx中文文档-ngx_http_index_module

ngx_http_index_module模块处理以斜杠“/”结尾的请求。这些请求也可以被ngx_http_autoindex_module和ngx_http_random_index_module模块处理。

示例配置

location / {
    index index.$geo.html index.html;
}

index

语法:index file
默认:index index.html
上下文:http, server, location

定义一个作为索引的文件。file可以包含变量。文件将按照指定的顺序检查。列表中最后一个元素可以是一个文件的绝对路径,例如:
index index.$geo.html index.0.html /index.html
需要注意的是,使用索引文件会产生内部重定向,请求会被一个不同的location处理。例如,下面的配置:

location = / {
    index index.html;
}

location / {
    ...
}

“/”请求将会实际会作为“/index.html”处理。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

请开启浏览器JavaScript