Rewrite variables
A rewrite variable is an object that stores a dynamic value like an entry path of a request or a session id. Rewrite variables are represented as strings in the format %<variable name>%
or %<variable name>[argument]%
. They are, for example, useful to define generic rewrite rules independent of the selected mapping, virtual host, or back-end group.
For pattern and substitution:
| For redirect locations:
|
For variable-specific exceptions, see the table below.
List of rewrite variables
Variable names in the table starting with %ENTRY...
refer to front-end use, while %BACKEND...
refer to back-end use. Variables with a different naming scheme are either specified in the description column or of general use.
Variable name | Description | Not available in |
---|---|---|
| Current request protocol from the client, HTTP or HTTPS. |
|
| Entry host of the current mapping, without port. |
|
| Entry host port number of the current mapping. |
|
| Entry path of the current mapping and the specified mapping name trimmed of trailing slashes, empty for root entry path. Example: |
|
| Same as Example: |
|
| Back-end path of the current mapping trimmed of trailing slashes, empty for root back-end path. Example: |
|
| Same as Example: |
|
| Back-end protocol, http or https. |
|
| Back-end host for this request is dynamically set based on the current load-balancing back-end host, without port. |
|
| Port number of back-end host. |
|
| Combined value of back-end host and port – omitting default ports: |
|
| The cookie domain is configured in the virtual host. |
|
| Current request id. |
|
| Current session id; “<n/a>” if no session is available, |
|
| Front-end SSL session ID, same value as the environment cookie AL_ENV_SSL_SESSION_ID. |
|
| Front-end SSL protocol, same value as the environment cookie AL_ENV_SSL_PROTOCOL. |
|
| Front-end SSL cipher suite, same value as the environment cookie AL_ENV_SSL_CIPHER. |
|
| Front-end SSL client subject name, same value as the environment cookie AL_ENV_SSL_CLIENT_S_DN. |
|
| Timing information in seconds. |
|
| Current audit token. |
|
| Current IP address of the client (front-end). |
|
| Role information, all timings in seconds: |
|
| IP address of current entry host. |
|
Example
The following example demonstrates how an incoming URL such as https://example.com/webmail/inbox/index.html
can be rewritten using the related variables.
URL part | Related variable | Example values |
---|---|---|
Entry protocol |
|
|
Entry host |
|
|
Entry path |
|
|
Back-end protocol |
|
|
Back-end host |
|
|
Back-end path |
|
|
Using the variables and values from the table above, we get the following solution:
Incoming URL |
|
---|---|
Rewrite from |
|
Rewrite to |
|
Back-end URL results in |
|
If a variable is unavailable, e.g., %SSL_CIPHER%
in case of HTTP, the action, e.g., Replace with will not be processed.
Literal mode
All variables are treated as literal values - characters do not have any special regular expression significance. This means, that the variable value www.example.com
just matches www.example.com
and not www-example/com
nor wwwXexampleYcom
.
Technically this is achieved by internally surrounding all variables by an extra \Q .. \E
span.
Further information and links
Internal links: