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.
Example:
https://de.domain.tld (for German customers) https://en.domain.tld (for british customers) https://us.domain.tld (for US visitors)
e.g.
Then…
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
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
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.
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: (ip.geoip.country eq "IT" and not http.host in {"it.domain.dev"} and not http.cookie contains "country=true")
or US+CA (ip.geoip.country eq "US" and not http.host in {"en.domain.dev"}) or (ip.geoip.country eq "CA" and not http.host in {"en.domain.dev"})
now I want to redirect all visitors from countries where no rule exist, to the subpath domain.dev/en
so I created the following rule set
(not http.host contains "en.domain.dev/en") or (ip.geoip.country ne "FR" and http.host in {"en.domain.dev/en" "en.domain.dev" "fr.domain.dev/en" "fr.domain.dev"}) or (ip.geoip.country ne "ES" and http.host in {"es.domain.dev" "en.domain.dev/en" "en.domain.dev" "es.domain.dev/en"}) or (ip.geoip.country ne "IT" and http.host in {"it.domain.dev" "en.domain.dev/en" "en.domain.dev" "it.domain.dev/en"}) or (ip.geoip.country ne "CA" and http.host in {"us.domain.dev" "en.domain.dev/en" "en.domain.dev" "us.domain.dev/en"}) or (ip.geoip.country ne "US" and http.host in {"us.domain.dev" "en.domain.dev/en" "en.domain.dev" "us.domain.dev/en"}) or (ip.geoip.country ne "DE" and http.host in {"de.domain.dev" "de.domain.dev/en" "en.domain.dev" "en.domain.dev/en"})
this ends in another redirect: https://en.ecow.dev/en/en/en/en/en/en/en/en