Create a 404 redirect to server on cloudflare

Please show me the detailed formula on how to create a redirect command.
Redirect all 404s to the homepage by cloudflare rule.
Thanks.

You can’t do that with a redirect rule, as it doesn’t care about the response. You would have to use a worker to check the response code and then return a redirect if it is a 404.

2 Likes

Or in your 404 page you could add HTML to set the location

<head>
<meta http-equiv="Refresh" content="0; url='https://yourwebsite.com/homepage'" />
</head>
<body>
<script>window.location.href = 'https://yourwebsite.com/homepage'</script>
</body>

1 Like

thanks so much.

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