博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nginx部署Npm打包的项目访问时F5刷新404
阅读量:3949 次
发布时间:2019-05-24

本文共 518 字,大约阅读时间需要 1 分钟。

Nginx部署Npm打包的项目访问时F5刷新404

文章目录

一、问题描述

使用nginx访问打包由npm build的项目dist文件夹发现了一个问题。除此访问一个页面是没有问题的,但是F5刷新之后就出现了问题

F5刷新之前

在这里插入图片描述

F5刷新之后

在这里插入图片描述

二、问题解决

后来寻找解决方法说是nginx的配置文件写错了。

修改之前

location / {            root   /etc/nginx/html/paperless/paperless_admin/dist;            index  index.html index.htm;        }

修改之后

location / {            root   /etc/nginx/html/paperless/paperless_admin/dist;            try_files $uri $uri/ /index.html; # 加上这个配置            index  index.html index.htm;        }

最后加上try_files $uri $uri/ /index.html;后可以访问了。

转载地址:http://jxgwi.baihongyu.com/

你可能感兴趣的文章
Elasticsearch-基础介绍及索引原理分析
查看>>
过滤敏感词算法
查看>>
linux学习之shell脚本if判断参数-n,-d,-f等
查看>>
linux学习之windos文件在linux里面乱码解决
查看>>
idea快捷键
查看>>
linux学习之shell遍历数组
查看>>
python函数取参及默认参数使用
查看>>
linux学习之shell中的${},##, %% , :- ,:+, ? 的使用
查看>>
Spring学习之Filter、Interceptor、Aop实现与区别
查看>>
Spring 添加@Autowired注释, 注入对象却为空
查看>>
springSecurity学习
查看>>
通过Java的api操作redis
查看>>
jquery基本选择器
查看>>
linux学习之shell字符串大小写转换
查看>>
Linux下用base64对字符串进行加密解密
查看>>
H5走迷宫小游戏
查看>>
mysql建表 表名与关键字冲突
查看>>
mysql 创建单表外键关联多表
查看>>
postman使用
查看>>
ClassNotFoundException和NoClassDefFoundError的区别
查看>>