GuideReference
TrainingSupportCommunity
Guide

rewrite_​url


Modifies the path of incoming requests to forward to the origin. This helps you offload URL-rewriting tasks to the edge to increase the origin server's performance, allows you to redirect links to different targets without changing markup, and hides your original directory structure.

Except for regular expression replacements, this behavior manipulates path expressions that start and end with a / character.

This behavior's rewrite operations can't override any the base​_directory behavior specifies.

OptionTypeDescriptionRequires
behaviorenum

The action to perform on the path.

{"displayType":"enum","options":["REPLACE","REMOVE","REWRITE","PREPEND","REGEX_REPLACE"],"tag":"select"}
REPLACE

Specify the match and target_​path. For example, a match of /path1/ and a target_​path of /path1/path2/ changes /path1/page.​html to /path1/path2/page.​html.

REMOVE

Specify the match. For example, a match of /path2/ changes /path1/path2/page.​html to /path1/page.​html.

REWRITE

Specify the target_​url. For example, you can direct traffic to /error/restricted.​html.

PREPEND

Specify the target_​path​Prepend. For example, if set to /prefix/, /path1/page.​html changes to /prefix/path1/page.​html.

REGEX_​REPLACE

Specify the match_​regex and target_​regex. For example, specifying logo\\.(png|gif|jpe?g) and brand\$1 changes logo.​png to brand.​png.

matchstring

When behavior is REMOVE or REPLACE, specifies the part of the incoming path you'd like to remove or modify.

behavior is either: REMOVE, REPLACE
{"displayType":"string","tag":"input","type":"text"}
{"if":{"attribute":"behavior","op":"in","value":["REMOVE","REPLACE"]}}
match_​regexstring

When behavior is set to REGEX_​REPLACE, specifies the Perl-compatible regular expression to replace with target_​regex.

behavior is REGEX_​REPLACE
{"displayType":"string","tag":"input","type":"text"}
{"if":{"attribute":"behavior","op":"eq","value":"REGEX_REPLACE"}}
target_​regexstring (allows variables)

When behavior is set to REGEX_​REPLACE, this replaces whatever the match_​regex field matches, along with any captured sequences from \$1 through \$9.

behavior is REGEX_​REPLACE
{"displayType":"string","tag":"input","type":"text"}
{"if":{"attribute":"behavior","op":"eq","value":"REGEX_REPLACE"}}
target_​pathstring (allows variables)

When behavior is set to REPLACE, this path replaces whatever the match field matches in the incoming request's path.

behavior is REPLACE
{"displayType":"string","tag":"input","type":"text"}
{"if":{"attribute":"behavior","op":"eq","value":"REPLACE"}}
target_​path​Prependstring (allows variables)

When behavior is set to PREPEND, specifies a path to prepend to the incoming request's URL.

behavior is PREPEND
{"displayType":"string","tag":"input","type":"text"}
{"if":{"attribute":"behavior","op":"eq","value":"PREPEND"}}
target_​urlstring (allows variables)

When behavior is set to REWRITE, specifies the full path to request from the origin.

behavior is REWRITE
{"displayType":"string","tag":"input","type":"text"}
{"if":{"attribute":"behavior","op":"eq","value":"REWRITE"}}
match_​multipleboolean

When enabled, replaces all potential matches rather than only the first.

behavior is either: REMOVE, REPLACE, REGEX_​REPLACE
{"displayType":"boolean","tag":"input","type":"checkbox"}
{"if":{"attribute":"behavior","op":"in","value":["REMOVE","REPLACE","REGEX_REPLACE"]}}
keep_​query_​stringboolean

When enabled, retains the original path's query parameters.

behavior is not REWRITE
{"displayType":"boolean","tag":"input","type":"checkbox"}
{"if":{"attribute":"behavior","op":"neq","value":"REWRITE"}}