• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
孙龙 程序员
少时总觉为人易,华年方知立业难
博客园    首页    新随笔    联系   管理    订阅  订阅
nginx的location详解

nginx的location详解

属于nginx核心模块中的功能,nginx核心功能.
location用于匹配用户请求中的uri的.
root /app/code/www/
www.oldboylinux.cn                   uri:/           
      /app/code/www/首页文件.
www.oldboylinux.cn/index.html       uri:/index.html 
      /app/code/www/index.html 
www.oldboylinux.cn/oldboy/lidao.jpg 
uri:/oldboy/lidao.jpg 
/app/code/www
2) 匹配规则

 

优先级:(了解)

 

正则: 用符号匹配有规律的内容.^ $  . * [] []+ | ()

server {
   listen 80;
   server_name l.oldboylinux.cn;
   default_type text/html;
   location / {
       return 200 "location /\n";
   }
   location = /index.html {
       return 200 "location =/\n";
   }
   location ~ /index.html {
       return 200 "location ~/\n";
   }
   location ^~ /index.html {
     return 200 "location ^~\n";
    }
}

 

 

本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/p/18391465

posted on 2024-09-01 17:13  孙龙-程序员  阅读(46)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3