rewriteUrl


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"}}