URL Rewrite
Overview
The URL Rewrite Traffic Policy action allows you to modify the incoming request URL using regular expressions before it reaches the upstream server, while keeping the URL seen by the client unchanged.
This action is particularly useful for routing users without exposing internal system details.
Configuration Reference
This is the Traffic Policy configuration reference for this action.
Supported Phases
on_http_request
Type
url-rewrite
Configuration Fields
fromstringCEL
A regular expression pattern used to match a part of the URL.
Supports CEL Interpolation.
tostringRequiredCEL
A regular expression pattern used to replace the matched part of the URL.
Supports CEL Interpolation.
Behavior
This action replaces all occurrences of the from
regular expression in the request URL with the to
replacement value.
Matching
Matching is performed against the entire URL, including the scheme, userinfo, host, and port, not just the path.
To match requests that begin with /products
, use CEL Interpolation and write ^${req.url.authority}/products
, or use an expression like req.url.path.startsWith('/products')
in the phase rule's expressions
field.
Note about CEL Interpolation
All CEL Interpolation will occur before regular expressions are evaluated.
Examples
Rewrite using Paths
The following Traffic Policy
configuration demonstrates how to use the url-rewrite
action to transparently
rewrite the request URL from /products
to /products.php
.
Example Traffic Policy Document
- YAML
- JSON
Loading…
Loading…
This configuration will rewrite any request to /products
to /products.php
without changing the URL seen by the client. This is useful for hiding away
the underlying implementation details of your service.
Example Request
Loading…
Loading…
Example Server Logs
Loading…