运维 | 了解 nginx 配置中 root 与 alias 的区别 | nginx
  bMJ94TEc8g8A 2023年11月02日 29 0

运维 | 了解 nginx 配置中 root 与 alias 的区别 | nginx

  • 官方 root
Sets the root directory for requests, For example, with the following configuration

location /i/ {
    root /data/w3;
}

The /data/w3/i/top.gif file will be sent in response to the /i/top.gif request

  • 官方 alias
Defines a replacement for the specified location, For example, with the following configuration

location /i/ {
    alias /data/w3/images/;
}

on request of /i/top.gif, the file /data/w3/images/top.gif will be sent.

当访问 /i/top.gif 时,root 是去 /data/w3/i/top.gif 请求文件,alias 是去 /data/w3/images/top.gif请求,也就是说 root 响应路径:配置路径+完整访问路径(网站的location配置路径+静态文件) alias 响应路径:配置路径+静态文件(去除location中配置的路径)

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  jnZtF7Co41Wg   2023年12月11日   14   0   0 nginx客户端服务端
  stLBpDewCLT1   2023年12月08日   21   0   0 nginx
  jnZtF7Co41Wg   2023年12月10日   16   0   0 nginx客户端服务端NFS
bMJ94TEc8g8A