Transform Rules - Modify Header (404)

I have a question with Cloudflare rules. I would like to set a rule

When incoming requests match URI Full contains for example xyz to set like in php a 404 header: header(“HTTP/1.0 404 Not Found”);

Is it possible in Cloudflare? I see that there are Transform Rules: Modify Request Header or Modify Response Header but i don’t know if this is the right function, which to choose and what to put in fields Header name and Value to get this 404 header.

Could you please help me with this issue?

What is your aim?

404 is not a header but an HTTP response status code. You can use a Redirect Rule to redirect these requests to a 404 page, or you can use a WAF rule to block the requests with status code 404.

The WAF solution requires a paid plan. I’m not sure if pro is enough or if business is required, can’t find this in the documentation right now.

On a free plan, you could block these requests with a 403 status code.

1 Like

I have a free plan and want to block requests with 404 code but at Cloudflare level, i don’t want to show 404 page in my domain. I know i can block requests with a 403 status code but i don’t know if google prefers 403 or 404 status code if pages don’t exists.

So the aim is to reduce server load by making these requests not reach your server?

Yes, but also these pages are indexed in google and i want to deindexed them, so i thought that 404 status would be more appropriate.