`

nginx 代理react-router 单页面入口配置刷新问题

阅读更多

原文:http://nphard.me/2016/03/07/nginx-for-react/ (react-router 浏览器刷新,页面404,依靠nginx配置解决)

 

其实这个问题,上边这篇文章已经可以搞定,但是nginx 现在推荐try_files 方式来搞定她,不推荐rewrite了, 所以可以这样配置:

       location /muc/{

             try_files $uri  /muc/index.html;

             root html;

        }

 

因为我的入口页面就是 muc目录下的index.html 页面, 所以当其余的不管几级参数:

/muc/A 、  /muc/A/B 、  /muc/A/B/C 、 /muc/A/B/C/D     等都来查找页面不存在,则直接返回到入口页面即可;

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics