nginx root与alias
2022/7/8 5:21:26
本文主要是介绍nginx root与alias,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
alias path; 定义指定路径的替换路径,也叫别名路径,文档映射的另一种机制;仅能用于location上下文
location /images/{ root指令:给定的路径对应于location的“/”这个URL
root /data/imgs/ 访问:/images/test.jpg --》 /data/imgs/images/test.jpg
}
location /images { alias指令:给定的路径对应于location的“/url/”这个URL, 注意: /images 后建议不要加 /
alias /data/imgs/ 访问:/images/test.jpg --》 /data/imgs/test.jpg
}
注意:location中使用root指令和alias指令的意义不同
(a) root,给定的路径对应于location中的/uri 左侧的/
(b) alias,给定的路径对应于location中的/uri 的完整路径
(c)使用alias的时候location 的URI后面如果加了斜杠则下面的路径配置必须加斜杠,否则403.
实例: vim alias.conf server { listen 80; server_name alias.zjol.com.cn; charset utf-8; server_name alias.zjol.com.cn; charset utf-8; location /root { root /data/nginx/html/root; index index.html index.htm; } location /alias { alias /data/nginx/html/alias; index index.html index.htm; } }
tree
.
├── alias
│ └── index.html
└── root
└── root
└── index.html
这篇关于nginx root与alias的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29fail2ban nginx
- 2024-03-18install nginx proxy manager
- 2024-01-2444从零开始用Rust编写nginx,命令行参数的设计与解析及说明
- 2024-01-22比Nginx更好用的Gateway!
- 2024-01-17nginx daemon off
- 2023-12-30Nginx Vhost Traffic Status 是什么意思-icode9专业技术文章分享
- 2023-12-26使用nginx搭建creates.io镜像(稀疏索引)
- 2023-11-18centos7编译安装Nginx教程。
- 2023-11-02nginx启动命令和停止命令
- 2023-10-25Centos7系统Nginx负载均衡如何安装和配置?