vuex项目history模式下404问题的解决方案

在 ” etc/nginx/conf.d/  “路径下修改你的当前项目的conf文件

在location中添加,下文中加粗部分的代码,实现重写路径,以避免出现404。

location / {
  root /root/www/dist;
  index index.html index.htm;
  if (!-e $request_filename) {
    rewrite ^/(.*) /index.html last;
    break;
  }
}

其他解决方案请参考

https://blog.csdn.net/u011025083/article/details/80352301

或者官方vue的解决方案

https://router.vuejs.org/zh-cn/essentials/history-mode.html

猜你喜欢

转载自www.cnblogs.com/souphm/p/10946509.html