Detect when a visitor tries to load a non-existent page

What is the name of the domain?

What is the issue you’re encountering

Detect when a visitor tries to load a non-existent page. Care should be taken to ensure that your website doesn’t generate 404 errors for normal visitors. 404 errors generated for the following file types won’t trigger an offense: js, css, gif, jpg, jpeg, png, map, ttf, woff, woff2

What steps have you taken to resolve the issue?

I need some help to create a rule that help me to Detect when a visitor tries to load a non-existent page.
Care should be taken to ensure that your website doesn’t generate 404 errors for normal visitors.
404 errors generated for the following file types won’t trigger an offense:
js, css, gif, jpg, jpeg, png, map, ttf, woff, woff2

Hi there Francisco,

Can you please explain better what type of rule do you want to have on Cloudflare side?

Do you want to have a redirect to the main page for example?

Cheers!

@JaimeC I want some rules or workers that validate with my website map. Excluding 404 errors generated for the following file types will not result in a crime:
js, css, gif, jpg, jpeg, png, map, ttf, woff, woff2.

In this case, if someone wants to check my website outside my sitemap range, they will be blocked.

I hope I explained.
For example.
In my sitemap have the url www.testwebsite.com but in my sitemap dont exist the url www.testwebsite.com/test then block that user who want consult non-exist page.

Blocking visitors instead of serving 404 errors is not a common practice, ultimately 404 status code is there for a reason. Doing this may affect how crawlers interact with your web property, even if you’re still serving content referenced in the sitemap correctly.

For this reason, there is no out of box solution to achieve this. You can do something custom though, i.e. fetch your sitemap using a snippet on each request, parse it and serve conditional responses depending on the presence of request URL in the map object.

If you don’t want to write code, then look into Bot Management and Custom WAF rules to configure rules based on bot scores and / or hardcoded acceptable URLs.