Redirect conditions - geographic redirect

Hey guys !

I have a tld and a subdomain

They both point to the same netlify hosting. In my webapp, I do some detection based on domain to update the website accordingly.

I’m trying to use Netlify’s GeoIP redirect feature to achieve the following behavior :

  • Redirect any visitor from any EU country to the tld
  • Redirect any visitor from the rest of the world to the subdomain

So far I have the redirect from the subdomain to the tld working using the Country condition and listing every country code in Europe.

I think I could get the other part working doing the same thing : basically listing all country codes except for the EU ones. But seems like there might be a better way ? Like maybe redirecting any visitor to the subdomain when NOT matching any EU country. That way I don’t have to actually list all country codes in the world…

Thanks for your help !

Hey Simon!

Congratulations! You discovered the best way to do it. Sorry! There’s not a better way right now…

This is a pretty frequent feature request, a sort of “negative” matching for redirect rules and conditions (consider also: “redirect every path except one”). I’ve added this thread to our feature-request-tracker, which brings two benefits:

  1. so folks are encouraged to do the same thing as you, and spell out their use case in detail. It’s often the case that we have a workaround (such as the one you found), or that there is some other way to achieve their goal, plus that use case will inform our eventual feature development in case we do implement the feature.
  2. if you’ve indicated interest, we can follow up to let you know if we do ship the feature at some point in the future.

Hey !

Thanks for your help. Looking forward hearing about this feature in the future :slight_smile:


1 Like