nginx 目录结构如下:html下为部署的前端项目页面,分别为zuiyu和test,下面我将通过使用root和alias来访问
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; }
通过上面两个小例子,相信大家也已经看出来root和alias的区别了,不错alias就是别名,也就是使用alias配置项目地址的时候,可以直接配置到访问的项目文件夹,而使用root配置时,Nginx 会在的默认部署路径html下找到匹配uri中的文件夹,然后在该文件夹下查找index.html
以上就是Nginx中root与alias区别是什么的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号