nanamikon commented on a change in pull request #4152:
URL: https://github.com/apache/apisix/pull/4152#discussion_r622070431
##########
File path: apisix/plugins/redirect.lua
##########
@@ -129,17 +161,35 @@ function _M.rewrite(conf, ctx)
end
end
- if uri and ret_code then
- local new_uri, err = concat_new_uri(uri, ctx)
- if not new_uri then
- core.log.error("failed to generate new uri by: ", uri, " error: ",
- err)
- return 500
+ if ret_code then
+ if uri then
+ local new_uri, err = concat_new_uri(uri, ctx)
+ if not new_uri then
+ local msg = "failed to generate new uri by: " .. uri .. err
+ core.log.error(msg)
+ return 500
+ end
+
+ core.response.set_header("Location", new_uri)
+ return ret_code
+ elseif regex_uri then
+ local new_uri, n, err = re_sub(ctx.var.uri, regex_uri[1],
+ regex_uri[2], "jo")
+ if not new_uri then
+ local msg = "failed to substitute the uri " .. ctx.var.uri ..
Review comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]