美文网首页
nginx 在vue history 模式下的配置

nginx 在vue history 模式下的配置

作者: 明眸yh | 来源:发表于2020-09-18 09:34 被阅读0次

如下图所示,dist文件为vue打包完后的文件夹

image

nginx 配置如下

使用 try_files uriuri/ /index.html;使所有请求都指向index.html

 server {
        listen       8000;
        server_name  localhost;
        
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   dist;
            try_files $uri $uri/ /index.html;
        }
    # others code
}

在浏览器访问8000端口即可;

相关文章

网友评论

      本文标题:nginx 在vue history 模式下的配置

      本文链接:https://www.haomeiwen.com/subject/kevdyktx.html