Is it possible to redirect blocked traffic to another website?

Since most of our clients’ customer base are extremely local, I’m testing geo-blocking of some countries where most of the hacking attempts on our sites seem to be coming from. Blocking the traffic was easy and didn’t take long to implement at all.

Right now, if someone from a blocked country tries to access the site, they get that 1020 error page. Instead of that, is there a way to redirect blocked traffic to another website?

Thanks,

Cynthia

You can do this with a Worker.

If you would like to go down this route, then reply to the post and I or someone else can walk you through it :slight_smile:

I haven’t tried yet, but if you are using for example a Pro plan where you can create custom Cloudflare error pages, maybe there is a way to redirect a user using a HTTP meta refresh HTML tag for that specific error - just an idea and again, I haven’t tried if it works like that.

Moreover, kindly see more information about creating one on the article below:

You can try using the code from below - if it should work, the user would see 1020 error and then be redirected to some other page after 3 seconds:

    <!DOCTYPE html>
    <html>
       <head>
          <meta charset="utf-8">
          <meta http-equiv="Refresh" content="3;url=https://www.redirectpage.com" />
          <title> My 1XXX Level Custom Error page</title>
          <style type="text/css">
             html, body{
             background:black;
             color:white;
             text-align:center;
             }
             h1 { color:red;font-size:22px; }
             h2 { color:blue; }
             p {font-size:16px; color: orange; }
             small {font-size:10px; color: #2eadee; }
          </style>
       </head>
       <body>
          <h1> Dear Visitor, this is an 1XXX example for Custom Level Errors page</h1>
          <h2>::CLOUDFLARE_ERROR_1000S_BOX::</h2>
          <p> You can add a stylesheet CSS for more colors, etc. </p>
          <small> This is an example </small>
       </body>
    </html>

Maybe there is some Cloudflare app already for that, you could also check if so.

Is that something that requires a Pro plan or can it be done w/ the free plan as well? Definitely interested in learning more about it.

Workers is a $5/month plan.

The free plan would work if you are going to have under 100,000 requests a day, otherwise the $5 plan would be more suitable.

This where I keep losing track. Does the free plan let you use your own domain?

Yes, you can use any domain you have on CF with the free plan, but you are still limited to 100,000 requests a day unless you are on the paid plan. The following link is to the official Workers discord server if you are interested.

This topic was automatically closed after 30 days. New replies are no longer allowed.