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

7. nginx 在vue history 模式下的配置

作者: 我的昵称好听吗 | 来源:发表于2019-03-16 14:01 被阅读0次

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

image.png

nginx 配置如下

使用 try_files $uri $uri/ /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端口即可;

相关文章

网友评论

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

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