This document describes how to use the Performance & Delivery Rules builder to create rules to create URL redirects and rewrites. For general information about the Performance & Delivery Rules screen, see Configuring Performance and Delivery Rules in the Portal.
Redirects and rewrites only occur for rules that act in the request phase.
What's the difference between redirects and rewrites?
A redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. The web server returns a HTTP status, typically either 301 – Permanent or 307 - Temporary. Since the browser needs to be involved, this adds an additional round trip to the transaction.
A 301 redirect can be useful for search engine optimization (SEO) by causing the search engine to update the URL.
A rewrite is a server-side rewrite of the URL before it’s fully processed by the web server. This will not change what is seen in the browser because the changes are hidden from the user. No HTTP status request is returned to the browser, since the URL change is handled on the server side.
A rewrite can also be useful for SEO by using a friendly URL to hide a messy URL; for example,
can be used as a friendly URL to hide a URL on the server side like
Rewrites only allow the non-domain portion of the URL to be changed. That is, a rewrite can change the path of the request, but not the domain – so there is no opportunity for a customer to rewrite the URL to point outside of the current domain configuration. If a change of domain is required, the request must be redirected.
Creating a redirect/rewrite rule
- In the rule builder screen, select Rewrite/Redirect rule for Rule type:
- On the Conditions tab, keep the default setting of All pages if you want the rule to apply to any request, or choose Use criteria to specify conditions you want match requests against. (For details on setting conditions, see Configuring Performance & Delivery Rules in the Portal.)
- On the Actions tab, choose the Redirect action, then select Redirect or Rewrite for the Type.
If it's a redirect:
- provide the Redirect to domain or URL.
- select the desired Response code: Permanent (301) or Temporary (302).
If it's a rewrite:
- enter what you want the URL rewritten as in the Rewrite to field.
- Click Save to save the rule.
Here's an example of a rule to perform a simple redirect from acme.com to www.acme.com. The criterion is defined so that if the domain in a request is acme.com, the action will be a permanent redirect it to www.acme.com.
In the Conditions tab:
In the Actions tab: