You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/03/11 10:48:16 UTC
[GitHub] [apisix] shuaijinchao commented on issue #6547: request help: How to handle query in redirect encode_uri
shuaijinchao commented on issue #6547:
URL: https://github.com/apache/apisix/issues/6547#issuecomment-1064995944
`regex_uri ` not support nginx variables, please look here: https://github.com/apache/apisix/blob/b16c86e24377d19215286c57bff0813a2cfd6c8c/apisix/plugins/redirect.lua#L105-L112
about `append_query_string` descirbe:
Redirect query parameters set in `regex_uri` are explicit values rather than variables, enabling `append_query_string` at this time will append the set value to the URL.
refer to this case:
### Set Route
```bash
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri":"/foo/bar/*",
"plugins":{
"redirect":{
"regex_uri": [
"(.*)/bar(.*)",
"https://www.apache.org/apisix$2?t=gateway"
],
"append_query_string": true
}
},
"upstream":{
"type":"roundrobin",
"nodes":{
"127.0.0.1:1980":1
}
}
}'
```
### Test Route
```bash
$ curl "http://127.0.0.1:9080/foo/bar/hello?q=hello&a=world" -I
HTTP/1.1 302 Moved Temporarily
Date: Fri, 11 Mar 2022 09:44:01 GMT
Content-Type: text/html
Content-Length: 110
Connection: keep-alive
Location: https://www.apache.org/apisix/hello?t=gateway&q=hello&a=world
Server: APISIX/2.12.0
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org