2016-12-30 115 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; 
    } 
}