1. ngx.redirect(uri, status?)    301/302重定向

redirect  为外部重定向,有两种形式:

rewrite ^ /foo? redirect;  # nginx config   在 rewrite 阶段重定向
等价于
return ngx.redirect('/foo');  -- Lua code

rewrite ^ /foo? permanent;  # nginx config
等价于
return ngx.redirect('/foo', ngx.HTTP_MOVED_PERMANENTLY)  -- Lua code

301  Moved Permanently

永久移动。请求的资源已被永久的移动到新URI,返回信息会包括新的URI,浏览器会自动定向到新URI。今后任何新的请求都应使用新的URI代替。

302  Found

临时移动。与301类似。但资源只是临时被移动。客户端应继续使用原有URI。

    

   

    

   

  

  

2.  ngx.exec()          内部重定向

  exec 会直接进入另一个 location 做处理,并不会 返回 调用 它的地方。

3.  子请求

  res = ngx.location.capture( url )  返回一个包含四个元素的Lua表   res.status   res.header     res.body    res.truncated

  此函数是在一个函数里 调用, 通过 capture 子请求到另一个 location 做处理(获取文件内容等),再返回。

最新文章

  1. Java 虚拟机
  2. espcms会员二次开发文件说明——会员,时间格式
  3. css3弹性盒模型
  4. RevMan简单入门指南
  5. oracle建表并设置ID为自动增长
  6. 史上最详细的CocoaPods安装教程
  7. CI框架笔记
  8. (巨坑)改了tpl文件之后,前端效果没反应
  9. Type 'System.IO.FileStream' with data contract name 'FileStream:http://schemas.datacontract.org/2004/07/System.IO' is not expected.
  10. php之框架增加日志记录功能类
  11. java.util.concurrent并发包诸类概览
  12. hdu 4746 Mophues
  13. 我在GNU/Linux下使用的桌面环境工具组合
  14. oracle "记录被另一个用户锁定"
  15. Linux安装mysql5.7
  16. DCOMP——分散式计算
  17. LNMP分离部署
  18. jdk和jre区别
  19. terminate called after throwing an instance of 'std::bad_alloc'
  20. APK方法数超过65535及MultiDex解决方案

热门文章

  1. 用 mongodb + elasticsearch 实现中文检索
  2. vmware centos 桥接模式 联网记录
  3. python之路—从入门到放弃
  4. Shell编程——位置参数变量
  5. TCP三次握手及四次断开,TCP有限状态机
  6. 树的遍历 | 1079 理解题意+DFS
  7. 第02组 Beta冲刺(2/4)
  8. wpf “{DependencyProperty.UnsetValue}”不是属性“Background”的有效值。异常
  9. 多线程避免使用SimpleDateFormat及替代方案
  10. 别傻傻不知道 == 和 equals 的区别【面试系列】