Vue项目部署到Nginx后 路由404【已解决】

Vue项目部署到Nginx后 路由404【已解决】

添加一个@router的location,在/中添加try_files即可。

 server {
        listen       8013;
        server_name  xxx.com;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

         location / {
              root /www/wwwroot/xxx.com;
              #重点配置
              try_files $uri $uri/ @router;
              index  index.html index.htm;
          }
          #重点配置
          location @router {
              rewrite ^.*$ /index.html last;
          }
    }
原文地址:https://www.cnblogs.com/zhangruifeng/p/14922394.html