nginx解决VUE重定向刷新指向首页的方法

本篇内容介绍了“nginx解决VUE重定向刷新指向首页的方法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

当用户请求 http://localhost/example 时,这里的 $uri 就是 /example。 try_files 会到硬盘里尝试找这个文件。如果存在名为 /$root/example(其中 $root 是项目代码安装目录)的文件,就直接把这个文件的内容发送给用户。 显然,目录中没有叫 example 的文件。然后就看 $uri/,增加了一个 /,也就是看有没有名为 /$root/example/ 的目录。 又找不到,就会 fall back 到 try_files 的最后一个选项 /index.php,发起一个内部 “子请求”,也就是相当于 nginx 发起一个 HTTP 请求到 http://localhost/index.php。

` server { listen 808; #server_name rc.huanwei.tidecloud.com;

    root   /var/www/html;
    index  login.html index.htm;
    #rewrite /index.html /login permanent;

    location / {
            try_files $uri $uri/ [@router](https://my.oschina.net/u/2258684);
            index index.html;
    }

    location [@router](https://my.oschina.net/u/2258684) {
            rewrite ^.*$ /index.html last;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ {
            root /var/www/html/rc.huanwei.tidecloud.com;
    }

    location /api-customer {
           proxy_pass http://192.168.0.110:13200;
    }

}

“nginx解决VUE重定向刷新指向首页的方法”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!