zoukankan      html  css  js  c++  java
  • nginx + lua 的 跳转命令

    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( location,args )  返回一个包含四个元素的Lua表   res.status   res.header     res.body    res.truncated

      ngx.location.capture 是非阻塞的,ngx.location.capture可以用来完成http请求,当调用使用此命令,当前请求会跳转到location 去执行,最后会返回。

  • 相关阅读:
    hdu 4534 郑厂长系列故事——新闻净化 夜
    poj 1185 炮兵阵地 夜
    hdu 2586 How far away ? 夜
    C. Shaass and Lights 夜
    hdu 4536 XCOM Enemy Unknown 夜
    根据BAPI_PO_CREATE1创建采购订单
    301、404、200、304、500HTTP状态
    js检查Page.IsValid
    查看linq的生成语句
    uploadfile和Image实现图片预览
  • 原文地址:https://www.cnblogs.com/chenpython123/p/10904203.html
Copyright © 2011-2022 走看看