Redirect Rules: Check if cookie not set

Hi everyone,

I have question regarding Redirect Rules. Here is summary of what I’m trying to achieve:

CASE 1

  • User visits global www. site and there is no cookie _WC_Location is set.
  • Check for Geolocation and if geoip country is set to United States, it should redirect user automatically to us. subdomain

CASE 2

  • User visits global www. site and there is cookie _WC_Location is set.
  • Check Geolocation and if _WC_location doesn’t match geoip country, it should redirect user to corresponding subdomain or url. (I assume this should be done with regex)

P.S. I saw that Regex isn’t available for Pro plan, is there any way to achieve this result with Pro plan?

This is my Redirect Rules expression:
(http.request.uri.path eq “/” and ip.geoip.country eq “US” and http.cookie ne “__WC_Location=US” and not http.request.uri.query contains “location”)

However, even if cookie __WC_Location is set, it anyway redirects to the subdomain.

Thank you in advance!

Replace the ‘and http.cookie ne …’ with:
not any(lower(http.request.headers.values[*])[*] == "__WC_Location=US")

1 Like

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