Geo Redirects: How to Redirect Visitors by Country (SEO-Safe)

October 5, 2023
8 mins read
Geo Redirects: How to Redirect Visitors by Country (SEO-Safe)

Direct Answer

A geo redirect (country redirect) sends visitors to a different URL based on the country their IP address appears to come from. You can set one up in your CDN or host, for example a Cloudflare Redirect Rule on ip.src.country, a Netlify _redirects line with Country=de, or a few lines of middleware. For SEO, Google advises against forcing visitors (and Googlebot) onto a version based on IP: keep every country version on its own URL, link them with hreflang, and suggest the local version with a banner instead. If you do redirect by IP, use a 302, only on the entry page, and never redirect away from a country URL someone opened directly. Country domains you own (mybrand.de) are a different case: a plain 301 to the matching section (mybrand.com/de/) is safe.

"Redirect visitors by country" can mean two very different things. One is a fixed redirect: everything on mybrand.de goes to mybrand.com/de/, for every visitor. The other is a geo redirect: the same URL sends a visitor in Germany to /de/ and a visitor in France to /fr/, based on their IP address. The first is a normal redirect that search engines handle cleanly. The second changes what people (and crawlers) see depending on where they appear to be, and that is where most SEO problems come from.

This guide covers both: what Google says about IP-based redirection, the rules that keep a geo redirect safe, how to set one up on Cloudflare, Netlify, Vercel and Nginx, how to show local content without redirecting at all, and how to point your country domains at the right section.

Geo redirect, country redirect, IP redirect: what the terms mean#

  • Geo redirect / IP-based redirect: the server (or CDN) looks up the visitor's IP address in a geolocation database, gets a country code such as DE or FR, and redirects to a URL chosen for that country.
  • Language redirect: the same idea, but based on the browser's Accept-Language header instead of the IP address.
  • Country domain redirect: a ccTLD you own (mybrand.de, mybrand.fr) redirects to a fixed destination, usually the matching section of your main site. It does not look at the visitor at all.
Three ways to send visitors to their country version: a fixed 301 from a country domain to a section, a 302 geo redirect by IP, and a suggestion banner that lets the visitor choose

Is IP-based redirection bad for SEO?#

It can be, because search engines don't crawl from your visitors' countries. Google's documentation is direct about it:

  • Googlebot crawls with IP addresses based outside the USA, in addition to US-based IP addresses[1], and it sends requests without an Accept-Language header. A redirect that picks the version by IP or language may show the crawler only one version.
  • In its multi-regional guide, Google says to avoid automatically redirecting users from one language version to another[2], and not to use IP analysis to adapt your content, because IP location is "difficult and generally not reliable".
  • Google recommends a separate URL for each language or country version, links between the versions, and hreflang annotations that tell Google which URL is for which locale[3].

So a geo redirect is not a penalty in itself, but a careless one hides pages from Google, sends travellers and VPN users to the wrong store, and can trap people who want another version. For the general effect of redirects on rankings, see our guide to redirect types and their SEO effects.

If you redirect by country anyway: 6 rules that keep it SEO-safe#

  • Use a temporary redirect (302 or 307), not a 301. The destination depends on the visitor, so the move is not permanent, and browsers cache 301s. Our 301 vs 302 guide explains the difference.
  • Redirect only the entry point, usually the homepage. Never redirect someone away from a country URL they opened directly, such as a link to mybrand.com/fr/ shared with a reader in Germany.
  • Keep every country version reachable and linked. Add a visible country or language switcher to every page.
  • Add hreflang to every version, plus an x-default for the page that serves visitors outside your target countries.
  • Remember the visitor's choice in a cookie and respect it on the next visit, even if the IP says otherwise.
  • Treat Googlebot like any other visitor from its location. Serving crawlers something different from users is cloaking.

How to change website content by country without redirecting#

Often the better answer to "how do I change website content based on visitor country" is to not redirect at all:

  • Suggestion banner: load the page the visitor asked for and show "Looks like you're in Germany. Go to the German site?" with a button and a "Stay here" option. It follows Google's advice to link your other versions and let people switch, and it never hides a URL from crawlers.
  • Small local details on the same URL: show prices in the local currency or a local shipping note, while the main content stays the same for everyone. Google calls pages that change by locale "locale-adaptive" and warns that it may not see every variation, so keep anything you want indexed on its own URL.
  • Separate country URLs with hreflang: /de/, /fr/ or de.mybrand.com, each indexable on its own, so search sends people straight to their version and no redirect is needed.

How to set up a country redirect#

These examples redirect the homepage only, with a 302. Adjust the country codes (ISO 3166-1 alpha-2, such as DE, FR, GB) and paths to your site. Facts checked on each vendor's documentation in October 2026.

Cloudflare: a Redirect Rule on the visitor's country#

If your domain is proxied through Cloudflare, create a Redirect Rule (a single redirect) with a custom filter expression and a dynamic target. Cloudflare exposes the visitor's country as ip.src.country. Cloudflare's own example[4] sends visitors from GB and FR on the homepage to a country subdomain:

text# When incoming requests match (custom filter expression)
(ip.src.country eq "GB" or ip.src.country eq "FR") and http.request.uri.path eq "/"

# Then: Dynamic redirect, target URL expression
lower(concat("https://", ip.src.country, ".example.com"))

# Status code: Cloudflare's example uses 301; choose 302 for a geo redirect

Netlify: Country conditions in _redirects#

Netlify reads Country and Language conditions in the _redirects file[5]. Country codes are comma-separated with no spaces, and visitors can override the detected country with the nf_country cookie, which is how you make a switcher stick:

text# Visitors in Germany or Austria who open the homepage go to /de/
/  /de/  302  Country=de,at

# Visitors in France go to /fr/
/  /fr/  302  Country=fr

Vercel: Routing Middleware with geolocation()#

On Vercel, a middleware.ts file at the project root runs before each request, and the geolocation() helper from @vercel/functions[6] returns the visitor's country. Response.redirect() sends a 302 by default. Geolocation is not set during local development, so test on a deployment:

typescriptimport { geolocation, next } from '@vercel/functions';

export const config = { matcher: '/' }; // homepage only

const SITES: Record<string, string> = { DE: '/de/', AT: '/de/', FR: '/fr/' };

export default function middleware(request: Request) {
  // Respect a choice the visitor already made in your country switcher
  if (request.headers.get('cookie')?.includes('country_choice=')) return next();

  const { country } = geolocation(request);
  const path = country ? SITES[country] : undefined;
  if (path) return Response.redirect(new URL(path, request.url), 302);
  return next();
}

Nginx: the GeoIP2 module and a MaxMind database#

Nginx needs the third-party ngx_http_geoip2_module[7] and a country database such as MaxMind GeoLite2-Country (free with an account). Map the country code to a path, then redirect the homepage only:

nginx# http {} block
geoip2 /etc/nginx/GeoLite2-Country.mmdb {
    $geoip2_country_code default=US country iso_code;
}
map $geoip2_country_code $country_home {
    default "";
    DE /de/;
    AT /de/;
    FR /fr/;
}

# server {} block
location = / {
    if ($country_home) { return 302 $country_home; }
    # otherwise serve the default homepage
}

Whichever platform you use, test from more than one country before you rely on it: a VPN, a colleague abroad, or a remote check. Our free redirect speed test shows the status code, where the URL lands and whether HTTPS is valid, measured from Washington, Frankfurt and Tokyo. If something looks off, our guide to redirects that don't work lists the usual causes.

Is your redirect working? Enter your domain. You'll see the status code (301 or 302), where it lands, whether HTTPS is valid, and how fast it answers from Washington, Frankfurt and Tokyo, ranked against every redirect tested in the last 7 days.

Test my redirect

Country domains: point each ccTLD at its section#

Many brands own country domains they don't run as separate sites: mybrand.de, mybrand.fr, mybrand.com.au. They are common: around one account in four on RedirHub redirects at least one country-code domain (RedirHub platform data, October 2026). The clean way to use them is a fixed redirect to the matching section of your main site, not a geo redirect:

  • mybrand.de and mybrand.at → mybrand.com/de/, keeping the path, so mybrand.de/kontakt lands on mybrand.com/de/kontakt.
  • mybrand.fr → mybrand.com/fr/, and so on for each country.

Because the redirect depends only on the URL, every visitor and every crawler gets the same answer, so a 301 is the right code. If you are retiring separate country sites and folding them into one domain, treat it as a website migration: map each old URL to its new page rather than sending everything to one homepage.

How to redirect a country domain with RedirHub#

RedirHub does not route by visitor country; for that, use your CDN or host as shown above. What it does is the country-domain part: it answers for domains that have no website, keeps the path, and runs on 130 global edge locations (PoPs), close to each visitor. Here is the setup in the dashboard:

RedirHub New domain redirect screen: Redirect from mybrand.de and mybrand.at, Redirect to https://mybrand.com/de, 301 · Permanent and Keep the path selected, with What happens previews
  1. Start a new Domain Redirect in the RedirHub dashboard.
  2. In Redirect from, enter the country domain, for example mybrand.de.
  3. Click Add another source for each domain that should go to the same section, for example mybrand.at.
  4. In Redirect to, enter the section, for example https://mybrand.com/de.
  5. Under Redirect type, keep 301 · Permanent.
  6. Under Paths, choose Keep the path. The What happens panel shows that mybrand.de/kontakt goes to mybrand.com/de/kontakt.
  7. Click Create redirect.
  8. Open Connect DNS for each domain, choose Manual, add the records shown (an A record on @ pointing to 3.33.236.10 and the TXT record starting rehd-verify=), then click I've made the changes.
  9. Once the domain shows as connected, check it with the redirect speed test.

Root and www count as one domain, and HTTPS is issued and renewed for both through automatic HTTPS, so https://www.mybrand.de works too. With a long list of old country URLs, use bulk CSV import to map each one to its own new page.

Geo redirect on your CDN vs country domains on RedirHub#

Geo redirect on your CDN or hostCountry domain redirect on RedirHub
Decides byVisitor's IP country (or browser language)The URL: same answer for everyone
Typical status code302 / 307301
Works for domains with no hostingOnly if the domain is on that CDNYes; DNS and email stay where they are, only root/www records change
PathsYou write the rulesKeep the path or map each old URL to its own page; several source domains per redirect
HTTPSDepends on your setupIssued and renewed automatically for root and www
ReportingYour own analyticsClicks and unique visitors with bots filtered out; DNS re-checked every 10 minutes
CostUsually included in your CDN or host planFrom $49/month (Core), 14-day free trial

If your domain is already on Cloudflare, Netlify or Vercel and you only need a geo redirect on the homepage, the built-in tools above are enough and cost nothing extra. RedirHub is worth it when you have country domains without hosting that need to point at the right section, with paths and HTTPS handled for you.

Common mistakes with country redirects#

  • A 301 for a geo redirect. Browsers cache it, so a traveller who once visited from France keeps landing on /fr/ at home.
  • Redirecting every URL, not just the entry page. Shared links and search results then land on the wrong version.
  • No way out. Without a switcher and a remembered choice, visitors can't reach the version they want.
  • Missing hreflang. Google may show the wrong country's page in search, or treat the versions as duplicates.
  • Different content for Googlebot. Detecting the crawler and skipping the redirect for it is cloaking.
  • Country domains pointed at the homepage. Keep the path so old links reach the matching page.

Sources

  1. [1]Google Search Central: How Google crawls locale-adaptive pages
  2. [2]Google Search Central: Managing multi-regional and multilingual sites
  3. [3]Google Search Central: Localized versions of your pages
  4. [4]Cloudflare docs: Redirect visitors to country subdomains
  5. [5]Netlify docs: Redirect by country or language
  6. [6]Vercel docs: Routing Middleware API (geolocation)
  7. [7]ngx_http_geoip2_module (GitHub)

Frequently asked questions

A geo redirect sends a visitor to a different URL based on the country their IP address appears to come from, for example /de/ for visitors in Germany and /fr/ for visitors in France. It is usually set up in a CDN, a host's redirect rules or a few lines of server code.

It can be. Googlebot often crawls from US IP addresses and without an Accept-Language header, so an IP- or language-based redirect may hide your other country versions from it. Google advises against automatically redirecting users between language versions. If you do it, use a 302 on the entry page only, keep every version reachable, and add hreflang.

A 302 (or 307). The destination depends on who is visiting, so the move is not permanent, and browsers cache 301s. Use a 301 only for fixed redirects that are the same for everyone, such as mybrand.de to mybrand.com/de/.

Either show a banner that suggests the local version and lets the visitor choose, or keep separate country URLs (such as /de/ and /fr/) linked with hreflang. Small details such as currency can change on the same URL, but anything you want indexed should live on its own URL.

Create a Redirect Rule with a custom filter expression that checks ip.src.country, for example ip.src.country eq "DE" and http.request.uri.path eq "/", set the target URL, and choose a 302 for a geo redirect.

No. RedirHub redirects by URL, not by visitor location. It is a good fit for country domains such as mybrand.de that should point at a section of your main site, keeping the path and handling HTTPS. For IP-based routing, use your CDN or host.

Redirect each one with a 301 to the matching section of your main site, keeping the path (mybrand.de/kontakt to mybrand.com/de/kontakt). Keep them registered so the old links and emails keep working.

Trinayan Chakraborty

TC is the Operations Manager at RedirHub, leading the company’s operational strategy and execution to ensure reliable, scalable redirect infrastructure. He oversees internal processes, cross-team coordination, and platform readiness while supporting customers through complex redirect implementations. With a strong understanding of large-scale domain operations and real-world edge cases, TC plays a key role in aligning product and customer success to deliver stable, high-performance redirection solutions.