【发布时间】:2015-02-02 04:57:01
【问题描述】:
我正在尝试让 nginx 使用由 react-router 处理的基于 pushstate 的 uri。
一切正常,直到我尝试在二级 uri example.com/MyApp/users 上按 F5。
我的静态资源在example.com/MyApp/resources。
问题是,每当我尝试直接访问(或 F5)users 的视图时,nginx 都会尝试将我的资源加载到 example.com/MyApp/users/resources 中。
这是我的 nginx 配置文件:
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/ 无效。
【问题讨论】:
标签: nginx pushstate react-router