商城首页欢迎来到中国正版软件门户

您的位置:首页 > 编程开发 >Nginx中root与alias区别是什么

Nginx中root与alias区别是什么

  发布于2025-03-25 阅读(0)

扫一扫,手机访问

项目结构

Nginx 目录结构如下:html下为部署的前端项目页面,分别为zuiyutest,下面我将通过使用rootalias来访问

nginx
    --conf
    --logs
    --html
      --zuiyu
        --index.html
        --static
      --test
        --index.html
        --static

测试

访问zuiyu项目

  location /zuiyu {
    root html;
    index index.html;
  } 
  location /zuiyu {
    alias html/zuiyu;
    index index.html;
  }

访问test项目

 location /test {
    root html;
    index index.html;
  } 
  location /test {
    alias html/test;
    index index.html;
  }

总结

通过上面两个小例子,相信大家也已经看出来rootalias的区别了,不错alias就是别名,也就是使用alias配置项目地址的时候,可以直接配置到访问的项目文件夹,而使用root配置时,Nginx 会在的默认部署路径html下找到匹配uri中的文件夹,然后在该文件夹下查找index.html

本文转载于:https://www.yisu.com/zixun/728311.html 如有侵犯,请联系admin@zhengruan.com删除

热门关注