Rules examples·续

Add a request header with the current bot score Create a request header transform rule to add a X-Bot-Score HTTP header to the request with the current bot score.

Add request header with a static value Create a request header transform rule to add an X-Source HTTP header to the request with a static value (Cloudflare).

Add a request header for subrequests from other zones Create a request header transform rule to add an HTTP header when the Workers subrequest comes from a different zone.

Add a response header with a static value Create a response header transform rule to add a set-cookie HTTP header to the response with a static value (cookiename=value).

Normalize encoded slashes in URL path Create a URL rewrite rule (part of Transform Rules) to normalize encoded forward slashes (%2F) in the request path to standard slashes (/).

Remove a request header Create a request header transform rule (part of Transform Rules) to remove the cf-connecting-ip HTTP header from the request.

Remove a response header Create a response header transform rule (part of Transform Rules) to remove the cf-connecting-ip HTTP header from the response.

Rewrite blog archive URLs Create a transform rule to rewrite the URL format /posts/<YYYY>-<MM>-<DD>-<TITLE> to the new format /posts/<YYYY>/<MM>/<DD>/<TITLE>.

Rewrite path of moved section of a website Create a URL rewrite rule (part of Transform Rules) to rewrite everything under /blog/<PATH> to /marketing/<PATH>.

Rewrite path of archived blog posts Create a URL rewrite rule (part of Transform Rules) to rewrite any requests for /news/2012/... URI paths to /archive/news/2012/....

Rewrite path for object storage bucket Create a URL rewrite rule (part of Transform Rules) to rewrite any requests for /files/... URI paths to /....

Rewrite image paths with several URL segments Create a URL rewrite rule (part of Transform Rules) to rewrite any requests for /images/<FOLDER1>/<FOLDER2>/<FILENAME> to /img/<FILENAME>.

Rewrite URL query string Create a transform rule to rewrite the request path from /blog to /blog?sort-by=date.

Rewrite page path for visitors in specific countries Create two URL rewrite rules (part of Transform Rules) to rewrite the path of the welcome page for visitors in specific countries.

Set a response header with the current bot score Create a response header transform rule (part of Transform Rules) to set an X-Bot-Score HTTP header in the response with the current bot score.

Set response header with a static value Create a response header transform rule (part of Transform Rules) to set an X-Bot-Score HTTP header in the response to a static value (Cloudflare).

Perform mobile redirects Create a redirect rule to redirect visitors using mobile devices to a different hostname.

Redirect admin area requests to HTTPS Create a redirect rule to redirect requests for the administration area of store.example.com to HTTPS, keeping the original path and query string.

Redirect requests from one domain to another Create a redirect rule to redirect all requests to a different domain, maintaining all functionality, except for the discontinued HTTP service (port 80).

Redirect requests from one country to a domain Create a redirect rule to redirect all website visitors from the United Kingdom to a different domain, maintaining the current functionality in the same paths.

Redirect requests for a domain to a new domain Create a redirect rule to redirect all URLs for a domain to point to the root of a new domain, including any subdomains of the old domain.

Redirect requests to a different hostname Create a redirect rule to redirect all requests for smallshop.example.com to a different hostname using HTTPS, keeping the original path and query string.

Redirect local visitors to specific subdomains Create a redirect rule to redirect United Kingdom and France visitors from the example.com website's root path (/) to their localized subdomains https://gb.example.com and https://fr.example.com, respectively.

Redirect visitors to a new page URL Create a redirect rule to redirect visitors from /contact-us/ to the page's new path /contacts/.

Redirect from root to WWW Create a redirect rule to forward HTTPS requests from the root (also known as the “apex” or “naked” domain) to the WWW subdomain.

Redirect from WWW to root Create a redirect rule to forward HTTPS requests from the WWW subdomain to the root (also known as the “apex” or “naked” domain).

Remove locale from URL path Create a redirect rule to redirect visitors from an old URL format with locale information to a new URL format.

Was this helpful?

YesNo

On this page

Rules examples·续 - 图1Docs

{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/rules/examples/#page","headline":"Rules examples","description":"Example configurations for Transform Rules, redirects, origin rules, and more.","url":"https://developers.cloudflare.com/rules/examples/","inLanguage":"en","image":"https://developers.cloudflare.com/rules/examples/og.png?v=c5eb58ee74156c8b","dateModified":"2026-05-20","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Customize Cloudflare settings for matching incoming requests, such as security level and caching. title: Configuration Rules image: https://developers.cloudflare.com/rules/configuration-rules/og.png?v=a7c709ffcdb2d3e8


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/rules/llms.txt
Use this file to discover all available pages before exploring further.