我想要nginx
與基於PushState的uri一起使用,由react-router
處理。 一切工作正常,直到我嘗試F5在第二級烏里example.com/MyApp/users
。Nginx重寫pushstate靜態資源不會加載
我的靜態資源位於example.com/MyApp/resources
。 問題是,只要我嘗試直接訪問(或F5)users
的視圖,nginx就會嘗試加載example.com/MyApp/users/resources
中的資源。
這裏是我的nginx的conf:
location ~ ^/MyApp/ {
try_files $uri /MyApp/index.html last;
}
我是新來nginx的,所以我真的不知道如何一切正常......
編輯:
我改變了我conf對此:
location/{
if (!-e $request_filename){
rewrite ^(.*)$ /MyApp/index.html break;
}
}
現在訪問example.com/MyApp/users
作品,但example.com/MyApp/users/
沒有。