1. 項目直接部署到根目錄時
location ^~ / {
alias /bgi/sdb2/frontend/test/dist;
index index.html; #默認(rèn)訪問的文件
try_files $uri $uri/ /index.html; #目錄不存在則執(zhí)行index.html
}
2. 項目部署到子路徑時
假設(shè)子路徑為 /test/
location ^~ /test {
alias /bgi/sdb2/frontend/test/dist;
index index.html; #默認(rèn)訪問的文件
try_files $uri $uri/ /test/index.html; #目錄不存在則執(zhí)行index.html
}