1.路由默認是帶#的,有時我們感覺不美觀,就使其變為history模式,也就沒有#字符
2.# 如果找不到當前頁面(404),就返回index.html,重新分配路由
location ^~/prodTest/ { root C:/Users/Administrator/Desktop/gavinApp/testVue/my-project; try_files $uri /prodTest/index.html =404; expires 2h; }
3.實例:如果用戶請求路徑為: http://localhost:8070/prodTest/login
此時 $uri == /prodTest/login
定義 $document_root == C:/Users/Administrator/Desktop/gavinApp/testVue/my-project
首先會找 $document_root /prodTest/login下的文件 =>
nginx 會返回 404 =>
nginx 會逐次找 try_files 對應值路徑下的文件
找 $uri 也就是 $document_root /prodTest/login 又找不到,
然后就會 fall back 到 try_files 的下一個配置項 /prodTest/index.html 也就是相當於 nginx 發起一個 HTTP 請求到 $document_root/prodTest/index.html
注:nginx 中 try_files 的理解 http://www.cnblogs.com/begin00/p/5491410.html