url_rewrite
Rewrites request URLs using regex substitution and query parameter manipulation before the request reaches upstream.
On this page
Rewrites request URLs using regex substitution and query parameter manipulation before the request reaches upstream.
Configuration Notes
Operations are applied in declaration order, allowing complex multi-step transformations.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
operations | (RegexReplace | StripQueryParams | AddQueryParams | PreserveQueryParamsOnly)[] | no | Ordered list of rewrite operations to apply. |
operations[].regex_replace | any | one of | Regex-based path replacement. |
operations[].strip_query_params | any | one of | Remove named query parameters (denylist: drop these, keep the rest). |
operations[].add_query_params | any | one of | Append static key-value pairs to the query string. |
operations[].preserve_query_params_only | any | one of | Retain only the named query parameters, dropping all others (allowlist). |
allow_rewrite_override | bool | no | When true, suppresses the duplicate-rewrite validation error if another rewrite filter precedes this one. |
Example
filter: url_rewrite
operations:
- regex_replace:
pattern: "^/api/v1/(.*)"
replacement: "/api/v2/$1"
- strip_query_params:
- debug
- preserve_query_params_only:
- api-version
- user
- add_query_params:
source: gateway