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

FieldTypeRequiredDescription
operations(RegexReplace | StripQueryParams | AddQueryParams | PreserveQueryParamsOnly)[]noOrdered list of rewrite operations to apply.
operations[].regex_replaceanyone ofRegex-based path replacement.
operations[].strip_query_paramsanyone ofRemove named query parameters (denylist: drop these, keep the rest).
operations[].add_query_paramsanyone ofAppend static key-value pairs to the query string.
operations[].preserve_query_params_onlyanyone ofRetain only the named query parameters, dropping all others (allowlist).
allow_rewrite_overrideboolnoWhen 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