您当前的位置: 首页 >  nginx

Nginx:root与alias的区别

彭世瑜 发布时间:2019-10-29 19:51:31 ,浏览量:1

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的差别

关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 1浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.3138s