Page Rules deleted by Cloudflare?

Hi All,

I just went onto some of our sites and checked the Page Rules, only to see there are no page rules… yet the rules that I setup previously are still working…

The rules setup as follows:

I don’t see any reason they should have been removed… the odd thing is they’re still functioning even though they’re missing which means even if I wanted to remove them I couldn’t.

Kind Regards
~ Ryan

What is the website?

The redirect is a 301 permanent redirect so is being cached by Cloudflare for 2 hours and also your browser. Clear the Cloudflare cache and check in private/incognito mode to really check if the redirection is still in effect.

You can check if/when/who deleted the rule in the audit log
https://dash.cloudflare.com/?to=/:account/audit-log

1 Like

I’ve purged the cache and yet still the redirects are all working across multiple sites, multiple devices and checking with external tools they still redirect.

I’ve checked the audit logs and there is no mention, I even checked the audit logs that I download every month and there is no mention of them being modified or deleted.

Yet all of the domains have no page rules…Therefore I believe the rules do still exist but Cloudflare has an issue that is hiding them somehow…

Assuming this is the domain in your screenshot, apart from a redirect http->https, there is no redirect from https://securitypeople.com.au. The origin is returning 503 (and showing “Maintenance Mode” in a browser).

What did you set to redirect from and to?

curl -I http://securitypeople.com.au/
HTTP/1.1 301 Moved Permanently
Date: Thu, 23 Nov 2023 06:39:21 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Thu, 23 Nov 2023 07:39:21 GMT
Location: https://securitypeople.com.au/
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=i6HgSTT5w%2FAH0NlDDRdVZsn94YCaNJ1wQ2PS5vEvoI8qnDB1hjQn7JoKE4RQvoYCQqKLLymW21MZPkH66bZljCWGVD37%2F05%2FvOBtzgm3z3TzEQB0%2BFF%2F8w2DzeZwRwuOgVnOFoB8olgm2XxR32XEFUGVG68%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 82a76a1e9aa123eb-LHR
alt-svc: h3=":443"; ma=86400
Cf-Team: 1c9c80a717000023eb079eb400000001

curl -I https://securitypeople.com.au/
HTTP/2 503
date: Thu, 23 Nov 2023 06:40:10 GMT
content-type: text/html; charset=utf-8
x-dns-prefetch-control: on
x-ua-compatible: IE=edge
link: <https://securitypeople.com.au/wp-json/>; rel="https://api.w.org/"
link: <https://securitypeople.com.au/wp-json/wp/v2/pages/59>; rel="alternate"; type="application/json"
link: <https://securitypeople.com.au/>; rel=shortlink
retry-after: 600
x-litespeed-cache: hit
x-content-type-options: nosniff
referrer-policy: strict-origin-when-cross-origin
permissions-policy: midi=(),publickey-credentials-get=()
vary: User-Agent,User-Agent
x-xss-protection: 1; mode=block
content-security-policy: frame-ancestors 'self' *.jobadder.com *.refari.co chat.smartai.com.au; upgrade-insecure-requests;
strict-transport-security: max-age=31536000; includeSubDomains
x-turbo-charged-by: LiteSpeed
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=rc759%2BZRXSl18GH66xEJb7dvEofJbCbXOB3yMuqsNhwNortSIidR1knfkv4KQxXWO2fXP5z9Iltn4depFpIGwx27a1J%2FkWMhnEmzv%2FN%2BPPdsgXC8Tu%2Bz%2BL6pfEHrWkZn01iL2m3yMcwPGFW%2FPydrL1G3i0A%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 82a76b4addaa23eb-LHR
alt-svc: h3=":443"; ma=86400

I created the following script:

import requests
import json

# Cloudflare API credentials
EMAIL = "my email"
API_TOKEN = "my token here"

# This is the base URL for the Cloudflare API
BASE_URL = 'https://api.cloudflare.com/client/v4/'

# Set the headers for the request
headers = {
    'X-Auth-Email': EMAIL,
    'X-Auth-Key': API_TOKEN,
    'Content-Type': 'application/json'
}

# The domain for which you want to retrieve the page rules
DOMAIN = "domain.com"

# Function to get the zone ID for a given domain
def get_zone_id(domain):
    zones_endpoint = f"{BASE_URL}zones?name={domain}"
    response = requests.get(zones_endpoint, headers=headers)
    if response.status_code == 200:
        zones = response.json()
        for zone in zones.get("result", []):
            if zone["name"] == domain:
                return zone["id"]
    return None

# Function to get page rules for a given zone ID
def get_page_rules(zone_id):
    page_rules_endpoint = f"{BASE_URL}zones/{zone_id}/pagerules"
    response = requests.get(page_rules_endpoint, headers=headers)
    if response.status_code == 200:
        return response.json()
    else:
        return None

# Main process
zone_id = get_zone_id(DOMAIN)
if zone_id:
    page_rules = get_page_rules(zone_id)
    if page_rules:
        print(json.dumps(page_rules, indent=4))
    else:
        print("Failed to retrieve page rules.")
else:
    print("Zone ID not found for the domain.")

The output is:

{
    "result": [
        {
            "id": "12345678910",
            "targets": [
                {
                    "target": "url",
                    "constraint": {
                        "operator": "matches",
                        "value": "*oldwebsite.com/*"
                    }
                }
            ],
            "actions": [
                {
                    "id": "forwarding_url",
                    "value": {
                        "url": "https://newwebsite.com/$2",
                        "status_code": 301
                    }
                }
            ],
            "priority": 1,
            "status": "active",
            "created_on": "2020-08-18T01:22:18.000000Z",
            "modified_on": "2023-07-20T09:05:33.000000Z"
        }
    ],
    "success": true,
    "errors": [],
    "messages": []
}

But yet in the page rules, they do not exist…

Hi Ryan,

My name is Matt and I am PM for the Rules product I checked internally and can see the Page Rule in your zone.

Can you do me a favour? Try an incognito window without any extensions or another browser? I think something may be blocking the JS from loading? You may be able to see what is happening in the network bar by looking for https://dash.cloudflare.com/api/v4/zones/REDACTTEDf2fbb636f39dd/pagerules

Thanks,

Matt

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.