Skip to content

Examples

Explore the following examples for Rules.

54 examples

Disable compression for AVIF images

Create a compression rule to turn off compression for AVIF images, based on either the content type or the file extension specified in the request.

Change URI Path and Host Header

Learn how to adjust the URI path and Host header for incoming requests. This example demonstrates using both Transform Rules and Origin Rules to achieve simultaneous modifications.

Debugging logs

Send debugging information in an errored response to a logging service.

Set security headers

Set common security headers such as X-XSS-Protection, X-Frame-Options, and X-Content-Type-Options.

Sign requests

Verify a signed request using the HMAC and SHA-256 algorithms or return a 403.

Remove a request header

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

Remove a response header

Create a response header modification 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>.

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 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.

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.