You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| uri | string | False ||| New Upstream URI path. Value supports [NGINX variables](https://nginx.org/en/docs/http/ngx_http_core_module.html). For example, `$arg_name`. |
| regex_uri | array[string]| False ||| Regular expressions used to match the URI path from client requests and compose a new Upstream URI path. When both `uri` and `regex_uri` are configured, `uri` has a higher priority. The array should contain one or more **key-value pairs**, with the key being the regular expression to match URI against and value being the new Upstream URI path. For example, with `["^/iresty/(. *)/(. *)", "/$1-$2", ^/theothers/*", "/theothers"]`, if a request is originally sent to `/iresty/hello/world`, the Plugin will rewrite the Upstream URI path to `/iresty/hello-world`; if a request is originally sent to `/theothers/hello/world`, the Plugin will rewrite the Upstream URI path to `/theothers`. |
| headers | object | False ||| Header actions to be executed. Can be set to objects of action verbs `add`, `remove`, and/or `set`; or an object consisting of headers to be `set`. When multiple action verbs are configured, actions are executed in the order of `add`, `remove`, and `set`. |
You should receive an `HTTP/1.1 403 Forbidden` response.
508
+
509
+
### Dynamically Forward Requests in `radixtree_uri_with_parameter` Router Mode
510
+
511
+
The following example demonstrates how to extract part of the URL path using the `uri_param_*` variable and forward the value to the Upstream service in a new header. This example assumes that APISIX is operating in the `radixtree_uri_with_parameter`[router mode](../router-radixtree.md).
512
+
513
+
Create a Route as such:
514
+
515
+
```shell
516
+
curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
517
+
-H "X-API-KEY: ${admin_key}" \
518
+
-d '{
519
+
"id": "httpbin",
520
+
"uri": "/anything/user/:user_id/profile",
521
+
"plugins": {
522
+
"proxy-rewrite": {
523
+
"headers": {
524
+
"set": {
525
+
"X-User-Id": "$uri_param_user_id"
526
+
}
527
+
}
528
+
}
529
+
},
530
+
"upstream": {
531
+
"type": "roundrobin",
532
+
"nodes": {
533
+
"httpbin.org:80": 1
534
+
}
535
+
}
536
+
}'
537
+
```
538
+
539
+
`/anything/user/:user_id/profile` matches requests where `user_id` is a Route parameter. The Plugin is configured to assign the `user_id` parameter value to a new header `X-User-Id`.
0 commit comments