React-Router browserHistory浏览器刷新出现页面404解决方案
2024-08-29 21:19:22
在React项目中我们经常需要采用React-Router来配置我们的页面路由,React-Router 是建立在 history 之上的,常见的history路由方案有三种形式,分别是:
1.hashHistory
2.browserHistory
3.createMemoryHistory
如果使用hashHistory
,访问的页面url如 example.com/#/some/path
的路由。
于是采用第二种browserHistory,但是部署到自己的服务器之后,可以正常访问,但是强制刷新页面之后报404找不到页面路径
Nginx配置方式如下
server {
server_name react.thinktxt.com;
listen 80; root /Users/txBoy/WEB-Project/React-Demo/dist;
index index.html;
location / {
try_files $uri /index.html;
}
}
访问后刷新,解决404问题
最新文章
- peer not authenticated error
- mapreduce 模板
- dubbo 管理控制台 的安装 dubbo-admin
- device unauthorized &; ANDROID_ADB_SERVER_PORT 问题解决
- Google Code Jam 2010 Round 1C Problem B. Load Testing
- yii的常用配置文件
- C# JSON字符串序列化与反序列化
- C++ 文件读写方案选型
- @SuppressWarnings(unchecked)作用解释
- C++指针的操作和运算(转)
- vc根据域名获取IP地址 gethostbyname()函数
- json解包与json封包
- dm-verity
- SQLite3创建数据库的方法
- 初次认识dedecms和帝国cms内容管理系统
- oracle登陆提示“ora-01031 insufficient privileges”
- hive的jdbc使用
- JSON数据的解析和生成(Swift)
- mapreduce中控制mapper的数量
- centos7下安装配置redis3.0.4