Modify Outgoing Request Path

This behavior automates common URL rewriting tasks for incoming requests before they are forwarded to the origin.

Why you need it

Use this behavior to:

  • Offload the origin server from URL rewriting tasks and perform them at the edge to increase performance.
  • Direct certain requests to certain objects towards new sections of the origin without changing the references in the html pages.
  • Hide the origin directory structure from the public.

How it works

By default, the outgoing path and incoming path are the same, but you can make changes by replacing parts of the path, setting the entire path to a static value, or adding values to the beginning of the path.

The behavior is controlled by the first option, Action, which defines what the ​Akamai​ edge server does with the incoming requests.

Features and options

Remove part of the incoming path

This identifies a path component in the incoming URL and removes it before forwarding it to the origin. When this operation is selected, use the Find in Incoming Path field to specify which component needs to be removed. A path component is similar to a directory structure and must begin and end with a /. The format of the path component is enforced by Property Manager.

You can optionally use the Keep the Query Parameters option to define how query strings are handled with these requests. This defaults to Yes to preserve incoming query strings.

Example

  • Incoming URL: http//www.customer.com/path1/path2/page.html?param=2

  • Find in Incoming Path: This is set to /path2/.

  • Keep the Query Parameters: This is set to Yes.

  • Resulting forwarded URL after rewrite: http//www.customer.com/path1/page.html?param=2

The edge server looks for all occurrences of path2 in this case and removes them. For example, if the incoming URL was http//www.customer.com/path1/path2/path3/path2/page.html, then the forwarded URL is http//www.customer.com/path1/path3/page.html.

Replace part of the incoming path

This identifies a path component in the incoming URL and replaces it with another path component before forwarding it to the origin. When selected, use the Find in Incoming Path field to specify which component needs to be replaced. Then, specify the replacement in Replace With. Ensure that both fields include valid path components.

You can optionally use Keep the Query Parameters to define how query strings are handled with these requests. This defaults to Yes to preserve any incoming query strings.

Example

  • Incoming URL: http//www.customer.com/path1/tobereplaced/page.html?param=1

  • Find in Incoming Path: This is set to /tobereplaced/.

  • Replace With: This is set to /replacement/.

  • Keep the Query Parameters: This is set to No.

  • Resulting forwarded URL after rewrite: http//www.customer.com/path1/replacement/page.html

The edge server looks for all occurrences of /tobereplaced/ in this case, and replaces them. For example, if the incoming URL was http//www.customer.com/path1/tobereplaced/path3/tobereplaced/page.html, then the forwarded URL is http//www.customer.com/path1/replacement/path3/replacement/page.html

Prepend the incoming path

This adds a path component prefix to the beginning of the incoming URL. When selected, use Prepend with to specify the prefix.

You can optionally use Keep the Query Parameters to define how to handle query strings are handled with these requests. This defaults to Yes to preserve any incoming query strings.

Example

  • Incoming URL: http//www.customer.com/path1/page.html?param=1

  • Prepend With: This is set to '/prefix/`.

  • Keep the Query Parameters: This is set to Yes.

  • Resulting forwarded URL after rewrite: http//www.customer.com/prefix/path1/page.html?param=1

Replace the entire path

Use this to replace the entire path after the initial URL with a path you define. When this operation is selected, use Replace with to specify the new path. Requests are forwarded to this new path.

Example

  • Incoming URL: http://www.customer.com/path1/page.html

  • Replace with: This is set to /new/url/index.html?param=1.

  • Resulting forwarded URL after rewrite: http://www.customer.com/new/url/index.html?param=1

Regular expression replacement

  • Perl compatible regular expression: Use this to specify match patterns you want to replace in the outgoing path. For example: ^(?i:\\Q/htdl\\E)

  • Replacement: Use this to specify the replacement operation that corresponds to the regular expression. You can use references to parts of the regular expression to perform the replacement.

πŸ“˜

With the Regular Expression Replacement option, format validation is not applied to the input fields. ​Akamai​ recommends that you thoroughly test these settings in the staging environment before your go live in production. Contact your ​Akamai​ technical representative with any questions.

You can determine how often these replacements happen

This is controlled by using the Occurrences setting. You can choose to replace or remove the old value the first time it appears, or every time it appears.

Other important considerations

  • All examples here assume that the incoming host header is being forwarded to the origin.
  • All rewrite operations change the cache-key, which may or may not affect the performance and offload of your property.

Did this page help you?