2016-12-30 80 views
2

我設立nginx的(1.10.2)VUE(2.1.x的),我有以下配置:VUE nginx的:路徑不匹配

location/{ 
    root /var/lib/myRepo/dist/; 
    index index.html; 
} 

這工作時,我打 'http://localhost:8080/',但當我打其他的網址,如: 'http://localhost:8080/products/home',我得到:

404未找到

我也嘗試以下操作:

root /var/lib/myRepo/dist/; 
location/{ 
    try_files $uri $uri/ index.html$query_string; 
} 

這裏有什麼可能是錯的,以及如何解決這個問題。

+0

如何'try_files $ URI $ URI/index.html的$ query_string'? (加個'?') –

+0

@潘俊傑潘俊傑感謝您的建議但沒有改進,仍然是同樣的問題。 – Saurabh

+0

試試這個'try_files $ uri $ args $ uri $ args/$ uri $ uri// index.html' –

回答

0

你可以按照這樣的:

server { 
    listen  80; 
    server_name localhost; 

    #charset koi8-r; 

    #access_log logs/host.access.log main; 

    location/{ 
     try_files $uri $uri/ @router; 
     index index.html; 
    } 

    location @router { 
     rewrite ^.*$ /index.html last; 
    } 
}