openresty ngx_lua重定向


openresty ngx_lua重定向

            

ngx.redirect:https://github.com/openresty/lua-nginx-module#ngxredirect

ngx.req.set_uri:https://github.com/openresty/lua-nginx-module#ngxreqset_uri

ngx.req.set_uri_args:http://​ https://github.com/openresty/lua-nginx-module#ngxreqset_uri_args

ngx.exec:http://​ https://github.com/openresty/lua-nginx-module#ngxexec

        

             

                                    

重定向

        

ngx.redirect:请求重定向

语法格式:ngx.redirect(uri, status?)
* 如果uri包含不安全的字符(控制字符),函数返回lua error
* status可选值:301、302(默认,临时重定向)、303、307、308

环境:rewrite_by_lua*, access_by_lua*, content_by_lua*


# 示例
return ngx.redirect("/foo")
return ngx.redirect("/foo", 301)
return ngx.redirect("/foo", 302)
return ngx.redirect("/foo", ngx.HTTP_MOVED_TEMPORARILY)

return ngx.redirect("http://www.google.com")


rewrite ^ /foo? redirect;  <==> return ngx.redirect('/foo')
rewrite ^ /foo? permanent; <==&g
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值