【Nginx/IIS】解决uniapp/Vue history模式下页面刷新404

uniapp/Vue 开启History模式

本地开发:二级页面刷新或者通过链接进入二级页面是正常的

打包部署后:二级页面刷新或者通过链接进入二级页面会报错404页面找不到

 

解决方案:

Nginx配置:

在nginx.conf的对应location里配置一行代码 try_files $uri $uri/ /index.html;

location /h5 {
  root /test/admin;
  index index.html;
  try_files $uri $uri/ /h5/index.html;
}

 

IIS配置:

在IIS配置流程:

 

 

 

 

 

 

posted @ 2023-12-07 19:41  编程民工  阅读(448)  评论(0编辑  收藏  举报