nginx

3-nginx配置多个前端项目

2018-11-27  本文已影响0人  Guoyubo

目的:

实现通过域名+项目名的方式访问不同前端项目

前提:

前端项目路径/front_page/infographic,这个里面直接是index文件


图片.png

nginx配置

用了root 和alias两种方式

       location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }

#前端测试alias !!!!!!!!!!
        #location /infographic {
    #       alias /front_page/infographic/;
      #         index  index.html index.htm; 
     #   }
#前端测试root !!!!!!!!!
    location /infographic {
               root /front_page;
               index  index.html index.htm;

        }

区别

root配置 :nginx直接转发至 root后面地址+location 后面地址
alias配置: nginx直接转发至 alias的地址,不会加上location后的内容
alias配置最后一定要 “/” 结尾 ,root随意

上一篇下一篇

猜你喜欢

热点阅读