Worker Redirect Issue

We are running a phpBB forum and we want to redirect certain countries to a particular post on our site. We created a Worker redirect for this, but when we tested it using a VPN and accessing our site from that particular country the Worker redirect doesn’t work. It starts to access the link after detecting the country, but then the browser times out and says too many redirects. As far as we know though there aren’t any added redirects involved with the redirect link we put into the Worker. It’s a direct link to the post that we put into the Worker for access by that country. We also tested the link directly outside of the Worker redirect and the link itself works normally. No errors. So it seems there is no issue with the link itself.

If we created a bitly or some other type of link and put that into the Worker instead would that work perhaps?

Could you please share the source and destination URLs so we can have a look? It would also be helpful if you could share the Worker’s source code.

Thank you. I read some stuff about “too many redirects” issues (you can click on the link above in my original post) and it seems Cloudflare already forces https so it’s not necessary to have that configured in the origin server.

And I think it might be our rewrite rule in the .htaccess file on our server that could be causing this endless loop of redirects.

Here is what we have now:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.oursite.com [NC]
RewriteRule (.*) https://oursite.com/$1 [L,R=301]

If we change https://oursite.com/$1 to http://oursite.com/$1 on the last line of the above then perhaps this will fix the problem?

I won’t be able to edit our .htaccess file until Friday to test it out, but just wondering if I am on the right track here at least.

Thanks.

I was able to temporarily delete our .htaccess file and it didn’t fix the issue. So it may not be that code causing the problem.

I also tried changing the redirect link in our Worker redirect code from https to http and it also had no effect.

Lastly, I tried disabling “Always Use HTTPS” under the Edge Certificates settings in the Cloudflare dashboard and that didn’t fix the too many redirects issue either.

I think I’ve tried everything I can think of now.