Rewrite rule causes error too many redirects

Hi all,
I configured a rewrite rule, to redirect all visitors out of a certain country (IP not equals “GB” for instance) to another page on the website, /site-out-of-bounds/ for instance. Unfortunately, for visitors outside if the setup country, any browser, when trying to access the site, is not being redirected to that URI, rather gets an error of “err_too_many_redirects”. What am I doing wrong or missing here? The domain setup to be proxied in the DNS zone (in CF).

Likely your rule is circular (triggering on both the input and the redirected link).

Can you show a screenshot of the rule?

1 Like

Thanks for the quick reply! Sure. there you go:

What is the domain name?

Your origin is doing a redirect to /site-na as well…
(look at the headers, this server is in the UK).

1 Like

My origin? In your link it is detailed that the second attempt also got a redirect response from a CF server, no?

By “origin”, do you mean something from the hosting server itself redirects again to /site-na? That’s weird, because I’ve disabled anything like it - I had a plugin and a code that tried to do the same, before using CF. I cleared/deleted them all, and now also cleared cache, but I think the issue still remains. Also, if you go to the site from the USA (via VPN for example), you won’t be redirected. What am I (still) missing?

It shows that the response was proxied through Cloudflare, but actual the response came from your origin. If you click the headers link you can see there are non-Cloudflare headers, including x-redirect-by: WordPress which tells you where the issue is.

HTTP/2 301
date: Tue, 27 Feb 2024 10:59:22 GMT
content-type: text/html; charset=UTF-8
cf-cache-status: DYNAMIC
access-control-allow-origin: *
age: 5829
cache-control: max-age=3600
expires: Tue, 27 Feb 2024 10:22:12 GMT
x-cache: HIT
x-redirect-by: WordPress
vary: Accept-Encoding
report-to: {"endpoints":[{"url":"https:\/\/\/report\/v3?s=j%2B46WdhUfbAph4U%2BSHXghRuvIxocfQExTj6tYc%2FPilUpZKiwuuiDGGtqRewkagxS6lSdAvKuYfTMCG7T9%2FGFmdSquNK8e%2FH0KugrC2vBeb8R0xupJK1Zt0JVKxBVIX8ypOkVrw%3D%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 85bfeaffb9a5633a-LHR
alt-svc: h3=":443"; ma=86400

This redirect then goes back through Cloudflare, which rewrites it (in this case changing nothing), then your origin redirects again, then back through Cloudflare… and so on until the browser gives up.


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