本视频由 保利威 提供技术支持

9. 解决前台 SPA 页面404

点击打开angular官方部署文档

try_files $uri $uri/ /index.html;

nginx查看配置项命令:

$ nginx -T | more

nginx原生配置:

    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

修正后的nginx配置:

    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }