使用 index 指令来指定默认首页文件,如果不存在,就是用 index.html。
server {
listen 80;
server_name ~(d+).domains.localhost;
root "D:/2vy-cc/server/nginx/html/domains";
location / {
index $1.html index.html;
}
}
D:2VY-CCSERVERNGINXHTMLDOMAINS
1.html
index.html
除了 index 指令,还可以用 try_files 指令
server {
listen 80;
server_name ~(d+).domains.localhost;
root "D:/2vy-cc/server/nginx/html/domains";
location / {
try_files /$1.html /$uri /index.html;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…