Transform Rules
Transform Rules allow you to adjust the URI path, query string, and HTTP headers of requests and responses on the Cloudflare global network.
There are several types of Transform Rules:
- Rewrite URL rules: Rewrite the URL path and query string of an HTTP request.
- HTTP request header modification rules: Set the value of an HTTP request header or remove a request header.
- HTTP response header modification rules: Set the value of an HTTP response header or remove a response header.
- Managed Transforms: Perform common adjustments to HTTP request and response headers with the click of a button.
To configure Transform Rules in the dashboard, go to the Transform Rules page in Rules.
For more complex header modifications and rewrite logic, consider using Snippets.
Cloudflare provides you with rules templates for common use cases. In the dashboard, go to your zone > Rules > Templates and select one of the available templates. You can also refer to the Examples gallery in the developer docs.
Alternatively, create a transform rule from scratch in the dashboard or via Cloudflare API. Refer to the following sections for detailed instructions:
- Rewrite URL rules
- HTTP request header modification rules
- HTTP response header modification rules
- Managed Transforms
Refer to Rules language for more information on building expressions for Transform Rules.
Cloudflare Transform Rules are available to all customers. Support for regular expressions depends on your Cloudflare plan.
This table outlines the Transform Rules features available with each customer plan:
Free | Pro | Business | Enterprise | |
---|---|---|---|---|
Availability | Yes | Yes | Yes | Yes |
Active Transform Rules | 10 | 25 | 50 | 100 |
Regex support | No | No | Yes | Yes |
A Cloudflare user must have the Firewall role or one of the Administrator roles to access Transform Rules.
Managed Transforms run before other types of Transform Rules that modify HTTP headers:
- Managed Transforms that adjust HTTP request headers run before HTTP request header modification rules.
- Managed Transforms that adjust HTTP response headers run before HTTP response header modification rules.
Transform Rules run in order. Rules that appear later in the list of Transform Rules can overwrite changes done by previous rules. You can define the rule order in the dashboard or via API.
Request and response fields are immutable within each phase while evaluating Transform Rules for a request/response. For more information, refer to Rule evaluation and field values.
When troubleshooting Transform Rules, use Cloudflare Trace to determine if a rule is triggering for a specific URL.