Page Rules migration guide·续2

How to replace:

  1. Create a configuration rule to turn off one or more security features:
  2. Email Obfuscation
  3. Hotlink Protection
  4. If required, create a WAF exception to skip one or more rules of WAF managed rulesets for requests coming from IP addresses in an allowlist.
  5. Turn off your existing Page Rule and validate the behavior of the rules you created.
  6. If your tests succeed, delete the existing Page Rule.

Caution

If you are still using WAF managed rules (previous version) or Rate Limiting (previous version), consider upgrading to the new versions of these products. It is not possible to turn off these older products using modern Rules features.

Migrate Disable Zaraz

Context:

You configured a Page Rule turning off Zaraz for all subdomains of example.com and the example.com domain itself:

  • URL: *example.com/*
  • Setting: Disable Zaraz

How to migrate:

  1. Create a configuration rule to turn off Zaraz for any hostname containing example.com:
  2. When incoming requests match: Custom filter expression
    • Using the Expression Builder:
      Hostname contains "example.com"
    • Using the Expression Editor:
      (http.host contains "example.com")
  3. Then the settings are:
    • Setting: Disable Zaraz
  4. Turn off your existing Page Rule and validate the behavior of the configuration rule you created.
  5. If your tests succeed, delete the existing Page Rule.
Page Rules configuration Migrate to a configuration rule
Example Page Rule with 'Disable Zaraz' setting Configuration rule matching the 'Disable Zaraz' setting of the example Page Rule

Migrate Edge Cache TTL

Context:

You configured a Page Rule adjusting Edge Cache TTL for all subdomains of example.com and the example.com domain itself:

  • URL: *example.com/*
  • Setting: Edge Cache TTL
  • Enter Edge Cache TTL: a day

How to migrate:

  1. Create a cache rule to adjust edge cache TTL for caching resources on Cloudflare edge to one day, for any hostname containing example.com:
  2. When incoming requests match: Custom filter expression
    • Using the Expression Builder:
      Hostname contains "example.com"
    • Using the Expression Editor:
      (http.host contains "example.com")
  3. Then:
    • Cache eligibility: Eligible for cache
    • Setting: Edge TTL
    • Ignore cache-control header and use this TTL
    • Input time-to-live (TTL): 1 day

Caution

The default behavior of Cache Rules is different from Page Rules. Refer to Key differences for more information. 2. Turn off your existing Page Rule and validate the behavior of the cache rule you created. 3. If your tests succeed, delete the existing Page Rule.

Page Rules configuration Migrate to a cache rule
Example Page Rule with the 'Edge Cache TTL' setting Cache rule matching the 'Edge Cache TTL' setting of the example Page Rule

Migrate Email Obfuscation

Context:

You configured a Page Rule turning off Email Obfuscation for all subdomains of example.com and the example.com domain itself:

  • URL: *example.com/*
  • Setting: Email Obfuscation
  • Value: Off

How to migrate:

  1. Create a configuration rule to turn off Email Obfuscation for any hostname containing example.com:
  2. When incoming requests match: Custom filter expression
    • Using the Expression Builder:
      Hostname contains "example.com"
    • Using the Expression Editor:
      (http.host contains "example.com")
  3. Then the settings are:
    • Setting: Email Obfuscation
    • Value: Off
  4. Turn off your existing Page Rule and validate the behavior of the configuration rule you created.
  5. If your tests succeed, delete the existing Page Rule.
Page Rules configuration Migrate to a configuration rule
Example Page Rule with 'Email Obfuscation' setting Configuration rule matching the 'Email Obfuscation > Off' setting of the example Page Rule

Migrate Forwarding URL

Example #1: Redirect www to root domain

Context:

You configured a Page Rule permanently redirecting www.example.com to example.com on all URI paths:

  • URL: www.example.com/*
  • Setting: Forwarding URL
  • Select Status code: 301 - Permanent Redirect
  • Destination URL: https://example.com/$1

How to migrate:

  1. Create a single redirect to permanently redirect requests from https://www.example.com to https://example.com. You can select the Redirect from WWW to Root rule template or enter the following rule configuration:
  2. If incoming requests match: Wildcard pattern
    • Request URL: https://www.example.com/*
  3. Then:
    • Target URL: https://example.com/${1}
    • Status code: 301
    • Preserve query string: Enabled
  4. Turn off your existing Page Rule and validate the behavior of the redirect you created.
  5. If your tests succeed, delete the existing Page Rule.

<details>

<summary>

Notes about the rule equivalence

</summary>

The provided example using Single Redirects is not an exact match for the previously existing Page Rule in the same example.

The exact equivalent would need to match both HTTP and HTTPS incoming requests, which you could achieve using a wildcard pattern like the following (notice the extra <code>*</code> after <code>http</code>):

  • Request URL: <code>http://www.example.com/</code>

This would require you to also change the Target URL to use the second wildcard capture group instead of the first one (corresponding to the text captured by second <code>*</code> in the wildcard pattern above):

  • Target URL: <code>https://example.com/${2}</code>

</details>

Page Rules configuration Migrate to a single redirect
Example Page Rule #1 with 'Forwarding URL' setting Single redirect matching the 'Forwarding URL' setting of the example Page Rule #1

Example #2: Redirect all pages under old path to new path

Context:

You configured a Page Rule permanently redirecting example.com/old-path to example.com/new-path:

  • URL: example.com/old-path/*
  • Setting: Forwarding URL
  • Select Status code: 301 - Permanent Redirect
  • Destination URL: https://example.com/new-path/$1

How to migrate:

  1. Create a single redirect to permanently redirect requests for example.com/old-path to example.com/new-path:
  2. If incoming requests match: Wildcard pattern
    • Request URL: https://example.com/old-path/*
  3. Then:
    • Target URL: https://example.com/new-path/${1}
    • Status code: 301
    • Preserve query string: Enabled
  4. Turn off your existing Page Rule and validate the behavior of the redirect you created.
  5. If your tests succeed, delete the existing Page Rule.

<details>

<summary>

Notes about the rule equivalence

</summary>

The provided example using Single Redirects is not an exact match for the previously existing Page Rule in the same example.

The exact equivalent would need to match both HTTP and HTTPS incoming requests, which you could achieve using a wildcard pattern like the following (notice the extra <code>*</code> after <code>http</code>):

  • Request URL: <code>http://example.com/old-path/</code>

This would require you to also change the Target URL to use the second wildcard capture group instead of the first one (corresponding to the text captured by second <code>*</code> in the wildcard pattern above):

  • Target URL: <code>https://example.com/new-path/${2}</code>

</details>

Page Rules configuration Migrate to a single redirect
Example Page Rule #2 with 'Forwarding URL' setting Single redirect matching the 'Forwarding URL' setting of the example Page Rule #2

Migrate Host Header Override

Context:

You configured a Page Rule changing the Host HTTP header to example.saas-provider.com, for all requests addressed at any subdomain of example.com and the example.com domain itself:

  • URL: *example.com/*
  • Setting: Host Header Override
  • Enter value: example.saas-provider.com

How to migrate:

  1. Create an origin rule changing the Host header to example.saas-provider.com for any hostname containing example.com:
  2. When incoming requests match: Custom filter expression
    • Using the Expression Builder:
      Hostname contains "example.com"
    • Using the Expression Editor:
      (http.host contains "example.com")
  3. Then:
    • Set origin parameters:
    • Host Header > Rewrite to: example.saas-provider.com
  4. Turn off your existing Page Rule and validate the behavior of the origin rule you created.
  5. If your tests succeed, delete the existing Page Rule.
Page Rules configuration Migrate to an origin rule
Example Page Rule with 'Host Header Override' setting Origin rule matching the 'Host Header Override' setting of the example Page Rule

Migrate IP Geolocation Header

Context:

You configured a Page Rule adding a CF-IPCountry HTTP header, for all requests addressed at any subdomain of example.com and the example.com domain itself:

  • URL: *example.com/*
  • Setting: IP Geolocation Header
  • Value: On

How to migrate:

  1. Turn on the Add visitor location headers Managed Transform — a Transform Rules feature — to add the CF-IPCountry and other location headers to all requests.
  2. Turn off your existing Page Rule and validate the behavior of the Managed Transform.
  3. If your tests succeed, delete the existing Page Rule.
Page Rules configuration Migrate to a Managed Transform
Example Page Rule with 'IP Geolocation Header' setting The 'Add visitor location headers' Managed Transform matching the 'IP Geolocation Header' setting of the example Page Rule

Migrate Opportunistic Encryption

Context:

You configured a Page Rule turning off Opportunistic Encryption for all subdomains of example.com and the example.com domain itself:

  • URL: *example.com/*
  • Setting: Opportunistic Encryption
  • Value: Off

How to migrate:

  1. Create a configuration rule to turn off Opportunistic Encryption for any hostname containing example.com:
  2. When incoming requests match: Custom filter expression
    • Using the Expression Builder:
      Hostname contains "example.com"
    • Using the Expression Editor:
      (http.host contains "example.com")
  3. Then the settings are:
    • Setting: Opportunistic Encryption
    • Value: Off
  4. Turn off your existing Page Rule and validate the behavior of the configuration rule you created.
  5. If your tests succeed, delete the existing Page Rule.
Page Rules configuration Migrate to a configuration rule
Example Page Rule with 'Opportunistic Encryption' setting Configuration rule matching the 'Opportunistic Encryption > Off' setting of the example Page Rule

Migrate Origin Cache Control

Context:

You configured a Page Rule turning off Origin Cache Control for all subdomains of example.com and the example.com domain itself:

  • URL: *example.com/*
  • Setting: Origin Cache Control
  • Value: Off

How to migrate:

  1. Create a cache rule to determine edge cache behavior for any hostname containing example.com:
  2. When incoming requests match: Custom filter expression
    • Using the Expression Builder:
      Hostname contains "example.com"
    • Using the Expression Editor:
      (http.host contains "example.com")
  3. Then:
    • Cache eligibility: Eligible for cache
    • Setting: Origin Cache Control
    • Enable Origin Cache Control: Off

Caution

The default behavior of Cache Rules is different from Page Rules. Refer to Key differences for more information. 2. Turn off your existing Page Rule and validate the behavior of the cache rule you created. 3. If your tests succeed, delete the existing Page Rule.

Page Rules configuration Migrate to a cache rule
Example Page Rule with 'Origin Cache Control' setting Cache rule matching the 'Origin Cache Control' setting of the example Page Rule

Migrate Origin Error Page Pass-thru