What I done now is redirect https://example.com/
to https://example.com/us
.
But I found a problem if US client access the URL like https://example.com/uk
will redirect to https://example.com/us/uk
.
My question is how to substring the /{geo} , my current dynamic expression is concat(“https://”,http.host,“/”,lower(ip.geoip.country),http.request.uri.path)
Assuming it’s a one-pager, where visitors from the US go to /us
, while visitors from the UK are sent to /uk
and no other paths are available, you could just remove the http.request.uri.path
from your expression:
concat("https://example.com/", lower(ip.geoip.country))
But if you do have many paths that you’d want to redirect to region-specific versions, so that /
is sent to /us
, and /help
is sent to /us/help
etc., then you could edit the "When incoming requests match’ expression so that it excludes other geo-location prefixes:
ip.src.country eq "US" and not http.request.uri.path in {/uk /dn /pt etc..}
Obs: ip.geoip.country
is being deprecated, and you should use instead ip.src.country