About Transform Rules
Transform Rules allow you to make adjustments to incoming requests at the edge before they go through any other Cloudflare products.
There are two types of Transform Rules:
- URL Rewrite Rules:
- Rewrite the path of the URL of an HTTP request
- Rewrite the query string of the URL of an HTTP request
- HTTP Request Header Modification Rules:
- Set the value of an HTTP request header
- Remove an HTTP request header
To configure Transform Rules in the dashboard, use the Transform Rules tab in Rules.
URL Rewrite Rules
A URL Rewrite Rule can perform a static rewrite or a dynamic rewrite. Static rewrites replace a given part of a request URL (path or query string) with a static string. Dynamic rewrites support more advanced scenarios where you use an to define the resulting path or query string.
Rewrites and redirects
You can manipulate the URL of a request through different operations, namely through rewrites and redirects.
A rewrite is a server-side operation that occurs before a web server has fully processed a request. A rewrite is not visible to website visitors, since the URL displayed in the browser does not change.
A redirect is a client-side operation that occurs after the web server has loaded the initial URL. In this case, a website visitor can see the URL changing when the redirect occurs.
You can configure URL Rewrite Rules in the dashboard to perform rewrites at the edge without reaching your web server. URL Rewrite Rules run in the
http_request_transform Phase of Cloudflare's request handling workflow. For more information on Phases, check the documentation.
HTTP Request Header Modification Rules
You can manipulate the headers of incoming HTTP requests through HTTP Request Header Modification Rules. Through these rules you can:
- Set the value of an HTTP request header to a literal string value, overwriting its previous value or adding a new header to the request.
- Set the value of an HTTP request header according to an expression, overwriting its previous value or adding a new header to the request.
- Remove an HTTP request header from the request (remove all headers with the provided name).
Cloudflare Transform Rules are available to all customers. Keep in mind that support for regular expressions is based on your plan type.
This table outlines the Transform Rules features available with each customer plan:
|Active URL Rewrite Rules||2||5||10||20|
|Active HTTP Request Header Modification Rules||2||5||10||20|
|Regular expression support||No||No||Yes||Yes|
To get started building your own Transform Rules, see: