react使用BrowserRouter打包后,刷新页面出现404
文档
https://gkedge.gitbooks.io/react-router-in-the-real/content/apache.html
nginx nginx.conf
server {
listen 80 default_server;
server_name /var/www/example.com;
root /var/www/example.com;
index index.html index.htm;
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}
location ~* \.(?:css|js)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public";
}
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
# Any route that doesn't have a file extension (e.g. /devices)
location / {
try_files $uri $uri/ /index.html;
}
}
apache 修改httpd.conf
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
如果出现上面的错误,找到 LoadModule rewrite_module 这行, 取消掉前面的注释
https://stackoverflow.com/questions/10144634/htaccess-invalid-command-rewriteengine-perhaps-misspelled-or-defined-by-a-m
<VirtualHost *:80>
ServerName localhost
DocumentRoot D:\\apache\\Apache24\\htdocs\\build
<Directory "D:\\apache\\Apache24\\htdocs\\build">
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
</Directory>
</VirtualHost>
react使用BrowserRouter打包后,刷新页面出现404的更多相关文章
- vue打包后刷新页面报错:Unexpected token <
前言 今天遇到了一个很怪的问题,在vue-cli+webpack的项目中,刷新特定页面后页面会变空白,报错为index.html文件中Unexpected token <. 怪点一是开发环境没有 ...
- response 后刷新页面,点击按钮后,禁用该按钮
一,正常的点击按钮后,将其灰显,全部执行完毕再正常显示. this.btnSave.Attributes.Add("onclick", "if (typeof(Page_ ...
- Ajax请求数据与删除数据后刷新页面
1.ajax异步请求数据后填入模态框 请求数据的按钮(HTML) <a class="queryA" href="javascript:void(0)" ...
- Vue build打包之后,刷新页面出现404解决方案
Vue build打包之后,刷新页面出现404,HTML5 History 模式 原因分析: vue-router 默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于 ...
- vue路由history模式刷新页面出现404问题
vue hash模式下,URL中存在'#',用'history'模式就能解决这个问题.但是history模式会出现刷新页面后,页面出现404.解决的办法是用nginx配置一下.在nginx的配置文件中 ...
- 解决React路由URL中hash(#)部分的显示 、browserHistory打包后浏览器刷新页面出现404的问题
摘要 在React项目中,我们需要采用它的路由库React-Router来进行页面跳转,React会根据路由URL来判断是哪个页面.常见的的URL有两种显示方式,一种是hashHistory的形式,形 ...
- 用HTTP状态码实现提交表单后刷新页面不重复提交
正常情况下,表单提交后如果用户刷新页面会重复提交表单,有些情况下我们不希望表单重复提交,利用HTTP协议中的307状态码重定向页面可以实现这个目的.实例如下: 表单页面代码: <form act ...
- Ajax异步调用http接口后刷新页面
使用Ajax的目的就是提高页面响应速度,无需同步调用,无需整个页面刷新.这里直接在html中使用js来实现: 先获取XMLHttpRequest对象 var xmlHttp; //创建一个xmlHtt ...
- <asp:TextBox><asp:LinkButton><input button>调用后台方法后刷新页面
<asp:TextBox><asp:LinkButton>服务器控件,执行后台方法,会回调加载js,相当于页面重新加载,刷新页面 <input button>不能直 ...
随机推荐
- Python3 与 C# 网络编程之~ 网络基础篇
最新版本查看:https://www.cnblogs.com/dotnetcrazy/p/9919202.html 入门篇 官方文档:https://docs.python.org/3/library ...
- Android的Databinding-单向绑定
两种方式实现观察绑定. 一.POJO类实现android.databinding.Observable,在属性set方法中调用notifyPropertyChanged(BR.lastName); 其 ...
- 发送HTTPS请求
package com.suning.epp.trt.util.r32epp; import java.io.BufferedInputStream; import java.io.IOExcepti ...
- Android:困扰了我一个晚上的问题 Failed to resolve: com.android.support:recyclerview-v7.25.3.1
为了解决这个问题,做了各种尝试: 1)重装sdk: 2)重装android studio: 最终发现是一个标点符号搞错了,如下: 而且通过查找这个问题,了解到: 1)sdk路径,<use ...
- zookeeper三节点集群安装记录
以下是3个节点的zk安装记录. 下载 下载地址: http://mirrors.shu.edu.cn/apache/zookeeper/ cd /data/opt/zk wget http://mir ...
- jQuery之end()和pushStack()
原文: https://www.cnblogs.com/AndyWithPassion/archive/2012/02/06/jquery_pushStack_javascript.html jque ...
- WPF 实现窗体拖动
C# 实现代码 this.Loaded += (r, s) => { this.MouseDown += (x, y) => { if (y.LeftButton == MouseButt ...
- [Python设计模式] 第15章 如何兼容各种DB——抽象工厂模式
github地址:https://github.com/cheesezh/python_design_patterns 题目 如何让一个程序,可以灵活替换数据库? 基础版本 class User(): ...
- vue:资源小记
github: https://github.com/keenleung/vue-tutorials 过滤器: https://segmentfault.com/a/1190000005027001 ...
- Easyui中 messager.alert 后某文本框获得焦点
messager.alert 后某文本框获得焦点 $.messager.alert({ title:'消息', msg:'电话号码 只能是数字!', icon: 'info', width: 300, ...