Excluding IP addresses from Geo Redirection Workers

Hi there,

Is it possible to exclude IP addresses from workers that handle geo redirection? The issue is that GoogleBot and gstatic (for analytics) are primarily based in USA. We redirect our users to subdomains based on their locations, which also presents an issue with indexing our website and subdomains on search engines. We’ve noticed that Google for example hasn’t been able to access our sitemap for the last few weeks. Google says on their website that their bot will attempt from other countries, but they don’t specify which countries those are.

This is an example of the redirection code for the worker:

export default {
  async fetch(request) {
     * A map of the URLs to redirect to
     * @param {Object} countryMap
    const countryMap = {
      US: "https://us.example.com",
      CA: "https://ca.example.com",
      UK: "https://uk.example.com",

    // Use the cf object to obtain the country of the request
    // more on the cf object: https://developers.cloudflare.com/workers/runtime-apis/request#incomingrequestcfproperties
    const country = request.cf.country;
    if (country != null && country in countryMap) {
      const url = countryMap[country];
      return Response.redirect(url);
    } else {
      return fetch(request);

It won’t let me post this topic as it includes URLs so I have to format this a bit strangely:

Here on this page we can see the IP addresses Google uses for their indexer/Googlebot: https://developers.google.com/search/apis/ipranges/googlebot.json

And here https://www.gstatic.com/ipranges/goog.txt, we can see the IP addresses used by gstatic (their analytics service.)

Presumably Microsoft might have published a similar thing, still need to do research that.

Anyway, back to the question, is there a way to incorporate these addresses into the worker to tell it to bypass these redirect rules if the request is coming from certain IP addresses? Not great with coding so I am not sure how to go about this.

Thank you

Also I apologize if I posted this in the wrong section. I wasn’t sure if I should post it here or in General, it seems the General section gets a lot more activity but it seemed more relevant here.

You can set radio for IP or ASN as well as country.

It’s also worth mentioning that you can now do static or dynamic redirects using flexible logic without needing a worker:

The example in the UI screenshot here shows you some of that type of logic:

You can build logic to only redirect specific IPs, or NOT specific IPs etc in this way.