Nginx:root与alias的区别

简介: Nginx:root与alias的区别

root目录:

root路径 + location路径

alias别名:

alias路径 替换 location路径

例:

location ^~ /dir/ {
    root /www/root/html/;
    # location = /www/root/html/ + /dir/
}
# 请求的URI: /dir/a.html时,返回 /www/root/html/dir/a.html
location ^~ /dir/ {
    alias /www/root/html/;
    # location = /www/root/html/
}
# 请求的URI:/dir/a.html时,返回:/www/root/html/a.html

注意

alias后面必须要用“/”结束,否则会找不到文件,root可有可无。

alias在使用正则匹配时,必须捕捉要匹配的内容并在指定的内容处使用。

alias只能位于location块中。(root可以不放在location中)

^~ 如果路径匹配那么不测试正则表达式

参考

nginx中的root与alias的差别

相关文章
|
2月前
|
前端开发 应用服务中间件 nginx
Nginx中root与alias区别
Nginx中root与alias区别
47 0
|
2月前
|
应用服务中间件 nginx
Nginx 配置中root和alias的区别分析
Nginx 配置中root和alias的区别分析
126 0
|
7月前
|
应用服务中间件 nginx
nginx中alias
nginx中alias
41 0
|
应用服务中间件 Linux nginx
重识Nginx - 06 搭建静态资源Web服务器(alias VS root)
重识Nginx - 06 搭建静态资源Web服务器(alias VS root)
214 0
|
应用服务中间件 nginx
Nginx:root与alias的区别
Nginx:root与alias的区别
128 0
|
应用服务中间件 nginx
nginx中root和alias的区别
nginx中root和alias的区别
nginx中root和alias的区别
|
数据建模 应用服务中间件 nginx
Docker - 解决创建 nginx 容器尝试挂载 nginx.conf 文件时报错: mounting "/root/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused: mount through procfd: not a directory:
Docker - 解决创建 nginx 容器尝试挂载 nginx.conf 文件时报错: mounting "/root/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused: mount through procfd: not a directory:
2926 0
|
应用服务中间件 nginx
NGINX虚拟目录alias和root目录
  假设nginx配置的域名是www.kazihuo.com,现有静态资源/home/www/oye目录需要通过nginx访问。 1、在nginx.conf中到处第二行添加内容‘include /usr/local/nginx/conf/conf.
1634 0
|
应用服务中间件 nginx
|
应用服务中间件 nginx