index
指令index用于设置网站的默认首页,它一般可以有两个作用:
一是,用户在发出请求访问网站时,请求地址可以不写首页名称;
二是,可以对一个请求,根据其请求内容而设置不同的首页。
该指令的语法结构为:
其中,file变量可以包括多个文件名,其间使用空格分隔,也可以包含其他变量。此变量默认为 “index.html”。
当location块接收到“/data/locationtest/web/”时,匹配成功,它首先将预置变量$1置为“locationtest”,然后在/data/locationtest/web/路径下按照index的配置次序依次寻找index.locationtest.html页、index.my1.html页和index.html页,首先找到哪个页面,就使用哪个页面响应请求。
Last updated
Was this helpful?