2016-09-28 415 views
0

如何將所有子目錄路徑重定向到單個index.html文件?nginx - 重定向子目錄路徑爲單個(index.html)文件

這裏就是我想nginx的配置:

location /user/* { 
    alias /home/vishant/devcenter/baetter-share1; 
    index index.html; 
} 

這意味着如果我打/用戶或/ user/vishant或/ user/XYZ/vishant應該只渲染index.html頁面。

我寫的代碼不起作用,但我認爲應該與此類似。

回答

0
location /user/ { 
    root /home/vishant/devcenter/baetter-share1; 
    try_files /index.html =404; 
} 

文檔:

+0

工作完美! –