Supported actions
Variable expansion works with the following Edge Rule actions:- Change Origin URL
- Redirect to URL
- Set Request Header
- Set Response Header
Syntax
Variables are accessed using the following syntax:Collection is a group of related variables, and Key is the specific value you want to access.
For a complete list of all available variables with examples, see Dynamic
Variables.
Variable collections
RequestHeaders
TheRequestHeaders collection contains HTTP headers from the incoming request. Headers are automatically mapped based on their name.
Query
TheQuery collection contains URL query parameters. Parameters are automatically mapped based on their key.
For a URL like ?token=abc123&user=42:
Request
TheRequest collection contains information about the HTTP request:
Path
ThePath collection allows you to extract specific segments from the URL path using index-based access.
For the path /hello/world/bunny/eat/carrot.jpg:
Url
TheUrl collection provides parsed components of the request URL:
User
TheUser collection contains information about the requesting user:
Server
TheServer collection contains information about the serving edge server:
Examples
Dynamic origin routing
Route requests to different origins based on the first path segment: Origin URL:https://%{Path.0}.backend.example.com/%{Path.1-}
For a request to /api/users/123, this becomes https://api.backend.example.com/users/123.
Pass query parameter as header
Forward a specific query parameter to your origin as a header: Header Name:X-Auth-TokenHeader Value:
%{Query.token}
Geo-based routing
Add the user’s country to the origin request: Header Name:X-CountryHeader Value:
%{User.CountryCode}
Related
- Dynamic Variables - Complete variable reference with all examples
- Rule Ordering - Control execution order for complex rule sets
- Middleware Scripts - For advanced request/response transformations