Redirect Rules and "redirected you too many times."


I have a Shopware Shop with a Lets Encrypt Cert which works fine. Now I’ve transfered my domain to Cloudflare, and I’m using the Proxy. Works well too.

Now I want to use the Feature why I’m switched to Cloudflare: Redirect users to different subdomains based on the visitor’s location.


https://de.domain.tld (for German customers)
https://en.domain.tld (for british customers)
https://us.domain.tld (for US visitors)

Every “Redirect Rule” looks like this:

Rule Name: Germany
Field: Country → Operator: equals → Value: Germany

Type: Static → URL: https://de.domain.tld → Status Code: 302

After that I only get in the Browser:
de.domaindottld redirected you too many times.

Under “SSL → Overview” I tried Flexible and Full with no effect.

Edge Certificate is
*.domain.tld, domain.tld → Universal → Active → 2023-09-13(Managed)

Always Use HTTPS
→ On (No effect if Off)

Anyone a recommendation what I could do? I’m completely stuck. When I remove the Redirect Rule, everything works as expected. Of course, the DNS settings are fine
A → subdomain → IP → Proxy On

Thanks a lot

You want to be on Full (Strict). No other option is secure

There is no context for it to understand that it redirected itself. It just sees the request to matching country, “ok let’s redirect them”, over and over.

There are two ways to go about this:
Add and hostname does not equal de.domain.tld, and they will only be redirected once. This has the downside of, if you add an unrelated subdomain like admin.domain.tld, German users would also be redirected away from that.
You could also do and hostname is in list en.domain.tld, us.domain.tld. You would have to type out all of your country specific hostnames for each rule, but this would be an explicit opt in and let you use other subdomains

Example, keeping path as well:

For easy copy pasting, the expression I used was

concat("https://de.domain.tld", http.request.uri.path)

Like in your original message, you might want to use a temp redirect code such as 302 instead of 301 as well, so it’s not cached/followed by search engines.

1 Like

Hey Chaica,

Thanks a lot. I directly tried it and it worked perfectly. Thanks a lot. I’ve another problem and perhaps you or anyone else can help me to figure out how to solve it.

I’ve different rules for different countries, in this example it’s Italy:
( eq "IT" and not in {""} and not http.cookie contains "country=true")

or US+CA
( eq "US" and not in {""}) or ( eq "CA" and not in {""})

now I want to redirect all visitors from countries where no rule exist, to the subpath

so I created the following rule set

(not contains "") or ( ne "FR" and in {"" "" "" ""}) or ( ne "ES" and in {"" "" "" ""}) or ( ne "IT" and in {"" "" "" ""}) or ( ne "CA" and in {"" "" "" ""}) or ( ne "US" and in {"" "" "" ""}) or ( ne "DE" and in {"" "" "" ""})

this ends in another redirect:

oh of course I’ve used the suggested URL redirect

DYNAMIC -> concat("", http.request.uri.path) -> 302