nginx部署前端项目-location root与 alias区别

1、location root : /path/uri(把匹配的路径追加到配置的路径:/demoProject追加到/usr/local/nginx/front/apps/demo)
     /demoProject {
        root /usr/local/nginx/front/apps/demo
    }
    当访问路径为:/demoProject/demo/demo.html时,
    实际访问路径为:/usr/local/nginx/front/apps/demo/demoProject/demo/demo.html

2、location alias: /path/uri(把匹配的路径替换为配置的路径:/demoProject替换为/usr/local/nginx/front/apps/demo)
     /demoProject {
         alias /usr/local/nginx/front/apps/demo
     } 
     当访问路径为:/demoProject/demo/demo.html时,
     实际访问路径为:/usr/local/nginx/front/apps/demo/demo/demo.html

 

posted @ 2023-03-06 21:55  scwyfy  阅读(94)  评论(0编辑  收藏  举报