Chapter 5: Action Reference
237
rewrite( )
Rewrites the request URL, URL host, or components of the specified header if it matches the
regular-expression pattern. This action is often used in conjunction with the URL rewrite form of the
transform action in a server portal application.
Note: The URL form of the rewrite( ) action does not rewrite some URL components for Windows
Media (MMS) transactions. The URL scheme, host, and port are restored to their original
values and an error logged if the URL specified by replacement_url attempts to change
these components.
An error results if the URL or URL host form of this action conflicts with another URL
rewriting action. The error is noted at compile time if the conflicting actions are within the
same action definition block. A runtime error is recorded in the event log if the conflicting
actions are defined in different blocks.
Similarly, an error results if two header modifications act on the same header.
HTTPS Limitation
Only the host and port are available for rewriting by the URL or URL host form when the client
browser is using a proxy for an HTTPS connection and the CONNECT or TUNNEL method is used.
This is because the URL path is encrypted and unavailable for rewriting.
Syntax
rewrite(url, regex_pattern, replacement_url[, URL_form1, ...])
rewrite(url.host, regex_pattern, replacement_host[, URL_form1, ...])
rewrite(header, regex_pattern, replacement_component)
where:
url—Specifies a rewrite of the entire URL.
url.host—Specifies a rewrite of the host portion of the URL.
header—Specifies the header to rewrite, using the following form. For a list of recognized
headers, see Appendix C.
request.header.header_nameIdentifies a recognized HTTP request header.
response.header.header_nameIdentifies a recognized HTTP response header.
request.x_header.header_name—Identifies any request header, including custom headers.
response.x_header.header_name—Identifies any response header, including custom
headers.
regex_pattern—A quoted regular-expression pattern that is compared with the URL, host or
header as specified, based on an anchored match. If the regex_pattern does not match, the
rewrite action is ignored. A regex_pattern match sets the values for substitution variables. If the
rewrite should always be applied, but no variable substitution is required for the replacement
string, specify ".* " for regex_pattern. For more information about regular expressions, refer to
Appendix E, “Using Regular Expressions,” in the Blue Coat ProxySG Configuration and Management
Guide.
replacement_url—A quoted string that can optionally include one or more variable
substitutions, which replaces the entire URL once the substitutions are performed. The resulting