Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/cn/docs/http/ngx_http_index_module.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Igor Sysoev
5
Copyright (C) Nginx, Inc.
6
-->
7
8
<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
9
10
<module name="ngx_http_index_module模块"
11
link="/cn/docs/http/ngx_http_index_module.html"
12
lang="cn"
13
translator="litianqing"
14
rev="1">
15
16
<section id="summary">
17
18
<para>
19
模块 <literal>ngx_http_index_module</literal> 处理以斜线字符(‘<literal>/</literal>’)结尾的请求。
20
</para>
21
22
</section>
23
24
25
<section id="example" name="配置范例">
26
27
<para>
28
<example>
29
location / {
30
index index.$geo.html index.html;
31
}
32
</example>
33
</para>
34
35
</section>
36
37
38
<section id="directives" name="指令">
39
40
<directive name="index">
41
<syntax><value>file</value> ...</syntax>
42
<default>index.html</default>
43
<context>http</context>
44
<context>server</context>
45
<context>location</context>
46
47
<para>
48
定义将要被作为默认页的文件。
49
文件 <value>file</value> 的名字可以包含变量。
50
文件以配置中指定的顺序被nginx检查。
51
列表中的最后一个元素可以是一个带有绝对路径的文件。
52
例子:
53
<example>
54
index index.$geo.html index.0.html /index.html;
55
</example>
56
</para>
57
58
<para>
59
需要注意的是,index文件会引发内部重定向,请求可能会被其它location处理。
60
比如,下面这个例子:
61
<example>
62
location = / {
63
index index.html;
64
}
65
66
location / {
67
...
68
}
69
</example>
70
请求“<literal>/</literal>”实际上将会在第二个location中作为“<literal>/index.html</literal>”被处理。
71
</para>
72
73
</directive>
74
75
</section>
76
77
</module>
78
79