首页 > 其他 > 详细

Nginx content阶段 static模块

时间:2019-02-14 17:06:58      阅读:216      评论:0      收藏:0      [点我收藏+]

alias指令 

syntax: alias path;# 静态文件路径  alias不会将请求路径后的路径添加到 path中

context : location;

root指令

syntax : root path; #静态文件路径 root会将请求路径后添加的 path中

context : http,server,location,if in location

      location /root {
                root html;
        }
        location /alias{
                alias html;
        }

        location ~/root/(\w+\.txt){
                root html/first/$1;
        }
        location ~/alias/(\w+\.txt){
                alias html/first/$1;
        }    

访问 http://xxxx/root 返回404 通过error日志 可以看到 会在html后加上root目录 

访问 http://xxxx/alias 返回nginx主页面 返回正确 

访问 http://xxxx/root/1.txt 返回404

访问 http://xxxx/alias/1.txt 则返回1.txt内容 

 

Nginx content阶段 static模块

原文:https://www.cnblogs.com/jackey2015/p/10375549.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!