In short
A forced IP-based redirect automatically sends visitors to the version for their presumed country: a user located in Germany who requests example.com/fr/tarifs/ lands on example.com/de/preise/ without having chosen it. The task is to remove these redirects wherever they hide (server, CDN, platform, application) and, if needed, replace them with a suggestion the visitor can ignore. Once done, every URL returns 200 in its own language, whatever country the request comes from.
Why it matters
Google asks you not to adapt content based on IP address analysis: IP-based location is unreliable and can prevent the site from being crawled properly. It also recommends avoiding automatic redirects to another language version and letting users choose, with links to the other versions.
The mechanism is simple. Googlebot mostly crawls from IP addresses that appear to be located in the United States, although it also uses addresses in other countries. If the server redirects every American visitor to the English version, the crawler can no longer reach the French or German versions: they drop out of the index or remain poorly understood. Google also states that it does not vary its crawler's location to discover variants: making them accessible is up to you.
Generative engine crawlers are exposed in the same way: they crawl from their publishers' address ranges, in only a few countries. An IP-based redirect hides the versions for other markets from them, and those versions then cannot be cited.
On the visitor side, IP geolocation is regularly wrong: VPNs, corporate networks, roaming mobile connections, travelers, cross-border commuters, expatriates. A French person on vacation in Barcelona does not want the Spanish version, and a shared link must open the page that was shared.
For e-commerce sites selling in the European Union, Regulation (EU) 2018/302 on unjustified geo-blocking in principle prohibits redirecting customers to another version of the online interface because of their nationality or place of residence without their explicit consent. Check your situation with your legal counsel.
What it improves
- Crawling and indexing of every version, whatever country the crawler crawls from.
- Citations in AI answers Every version stays readable for AI crawlers. Effect not guaranteed.
- Experience Travelers, VPN users and people who receive a shared link see the page they requested.
- Compliance Less risk with regard to European rules on geo-blocking.
- Caching No more responses that vary by country under the same URL.
- Rankings No direct effect, but versions that can finally be indexed.
How to check
1. From several countries. Request one URL from each version from different locations: a VPN, a remote server, or a probe service such as Globalping. Expected result: 200 everywhere, with no location header.
curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" https://example.com/fr/tarifs/
2. In the server logs. Look for redirects served to Googlebot on language pages:
grep "Googlebot" /var/log/nginx/access.log | awk '$9 ~ /^30[1278]$/ {print $9, $7}' | sort | uniq -c | sort -rn | head -20
A list of 302s on /fr/ or /de/ points to a geographic redirect. Apache logs are usually in /var/log/apache2/access.log.
3. In Search Console. Inspect one URL from each version: a language page reported as "Page with redirect" when no redirect is intended gives away a geographic rule. The Page indexing report lists these cases.
4. In the configuration. Search for geolocation modules and variables:
sudo grep -rn -i -E "geoip|maxmind|CF-IPCountry|ip.src.country|Viewer-Country|x-vercel-ip-country" /etc/nginx/ /etc/apache2/ /var/www/ 2>/dev/null
How to implement
Before you start
Target behavior:
- No automatic IP-based redirect, neither on language pages nor on the root.
- An optional suggestion: a discreet, dismissible banner offering the equivalent page in the version for the detected country, without hiding the content or blocking navigation.
- The same behavior for everyone, crawlers included. Google asks you to treat Googlebot coming from a country like any other visitor from that country: do not add an exception reserved for crawlers, which would look like cloaking.
- A language and country switcher that is always visible, with HTML links to the equivalent pages (see provide a crawlable language switcher (opens in a new tab)).
If the site root (example.com/) is used to guide visitors, make it a selection page annotated x-default, or serve the default version there with the banner (see define the default version (opens in a new tab)).
Suggestion banner (all environments)
The banner relies on two elements: a small uncached endpoint that returns the detected country, and a script that reads the hreflang annotations already present in the page to find the equivalent URL. The page HTML stays identical for everyone and can remain cached.
<div id="geo-suggestion" class="geo-suggestion" hidden>
<p>
<span id="geo-text"></span>
<a id="geo-link" href="#"></a>
</p>
<button type="button" id="geo-close">Stay on this version</button>
</div>
<script>
(async () => {
const banner = document.getElementById('geo-suggestion');
const suggestions = {
CH: { hreflang: 'fr-CH', text: 'Browsing from Switzerland?', link: 'See prices in CHF' },
DE: { hreflang: 'de', text: 'Diese Seite gibt es auch auf Deutsch.', link: 'Zur deutschen Version' },
};
try {
if (localStorage.getItem('geoSuggestionClosed')) {
return;
}
} catch (error) {}
const response = await fetch('/geo', { cache: 'no-store' });
if (!response.ok) {
return;
}
const { country } = await response.json();
const suggestion = suggestions[country];
if (!suggestion) {
return;
}
const alternate = document.querySelector(`link[rel="alternate"][hreflang="${suggestion.hreflang}"]`);
if (!alternate || alternate.href === location.href) {
return;
}
document.getElementById('geo-text').textContent = suggestion.text;
document.getElementById('geo-link').textContent = suggestion.link;
document.getElementById('geo-link').href = alternate.href;
banner.hidden = false;
document.getElementById('geo-close').addEventListener('click', () => {
banner.hidden = true;
try {
localStorage.setItem('geoSuggestionClosed', '1');
} catch (error) {}
});
})();
</script>
The /geo endpoint returns {"country":"CH"} with Cache-Control: private, no-store. The following sections explain how to feed it in each environment.
Apache
Versions Apache 2.4, mod_maxminddb module 1.x.
With the mod_maxminddb module and the GeoLite2 database, find and remove the redirect rules based on country:
# Remove: forced redirect based on country
RewriteCond %{ENV:MM_COUNTRY_CODE} ^DE$
RewriteRule ^fr/(.*)$ /de/$1 [R=302,L]
Keep the detection if you want to feed the banner, and pass the country to the application as a header:
<IfModule mod_maxminddb.c>
MaxMindDBEnable On
MaxMindDBFile COUNTRY_DB /usr/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE COUNTRY_DB/country/iso_code
</IfModule>
<IfModule mod_headers.c>
RequestHeader set X-Country-Code "%{MM_COUNTRY_CODE}e"
</IfModule>
Reload with sudo apachectl configtest && sudo systemctl reload apache2.
Nginx
Versions Nginx 1.24 and later, third-party module ngx_http_geoip2_module 3.x.
With the ngx_http_geoip2_module module, remove any return or rewrite conditioned on the country:
# Remove
if ($geoip2_country_code = DE) {
return 302 /de/;
}
Keep the variable for the /geo endpoint, in the http context and then in the server block:
geoip2 /usr/share/GeoIP/GeoLite2-Country.mmdb {
$geoip2_country_code country iso_code;
}
server {
# in the site's existing server block
location = /geo {
default_type application/json;
add_header Cache-Control "private, no-store" always;
return 200 '{"country":"$geoip2_country_code"}';
}
}
Reload with sudo nginx -t && sudo systemctl reload nginx.
Cloudflare
Versions Cloudflare dashboard, all plans, November 2026.
- Redirect rules: open
Rulesfrom the Rules Overview and look for rules whose expression containsip.src.country(or the olderip.geoip.countryfield). Disable those that redirect language pages, then delete them once the test is validated. - Workers: review the Workers' code for
request.cf.countryfollowed by aResponse.redirect. - Country for the banner: in the domain's
Networktab, turn on "IP Geolocation". Cloudflare then adds theCF-IPCountryheader to requests forwarded to your server, which your application's/geoendpoint can return.
Then purge the cache if redirects had been cached.
AWS
Versions Amazon CloudFront (CloudFront Functions and Lambda@Edge), AWS console, November 2026.
On CloudFront, geographic redirects are usually found in a CloudFront Function or a Lambda@Edge function associated with the "Viewer request" event, which reads the CloudFront-Viewer-Country header. Disassociate the function from the behavior, or remove the redirect branch, then publish and invalidate /*.
To feed the banner, forward CloudFront-Viewer-Country to the origin with an origin request policy, without adding it to the cache policy for HTML pages: otherwise each page would be cached once per country. The /geo endpoint must have its own behavior, with no caching.
CloudFront's built-in geographic restriction blocks entire countries: keep it for legal obligations, it is not a targeting tool.
Shopify
Versions Shopify admin, all plans, November 2026.
In the Shopify admin, under Online Store > Preferences, in the Automatic redirection section, turn off the Country/region option that redirects based on geolocation, then save. The Language option, which follows the browser language, falls under avoid forced redirects based on browser language (opens in a new tab). Keep a country and language selector in the theme; a geolocation app from the Shopify App Store can display a country recommendation instead of redirecting.
WordPress
Versions WordPress 6.4 and later, up to 7.1.
WordPress does not redirect by IP by default. Look for the cause in:
- geolocation or redirect plugins: disable the per-country rules;
- modules of multilingual plugins that detect the visitor's language or country, for example TranslatePress's automatic user language detection add-on: choose a suggestion display rather than a redirect;
- the host or the CDN: some managed plans offer geographic redirects at server level, to be disabled in their dashboard.
WooCommerce geolocation (WooCommerce > Settings > General, Default customer location) is used to calculate taxes and shipping: it does not redirect and can stay enabled.
Laravel
Versions Laravel 10 to 13.
Remove the middleware that redirects by country and expose the country for the banner:
// routes/web.php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::get('/geo', function (Request $request) {
$country = $request->header('CF-IPCountry') ?? $request->header('X-Country-Code');
return response()
->json(['country' => $country])
->header('Cache-Control', 'private, no-store');
});
Only trust these headers if the site can be reached solely through the CDN or proxy that sets them. Remove the /geo route from the session middleware if you do not want to set a cookie on this call.
Next.js
Versions Next.js 15 and 16 (App Router).
In proxy.ts (on Next.js 15: the middleware.ts file and the exported middleware function), remove the redirect based on country:
// Remove from proxy.ts
const country = request.headers.get('x-vercel-ip-country');
if (country === 'DE' && !request.nextUrl.pathname.startsWith('/de')) {
return NextResponse.redirect(new URL(`/de${request.nextUrl.pathname}`, request.url));
}
Instead, create a route for the banner:
// app/geo/route.ts
export const dynamic = 'force-dynamic';
export function GET(request: Request) {
const country = request.headers.get('x-vercel-ip-country')
?? request.headers.get('cf-ipcountry');
return Response.json(
{ country },
{ headers: { 'Cache-Control': 'private, no-store' } },
);
}
On Vercel, the x-vercel-ip-country header is added automatically; behind Cloudflare, use cf-ipcountry.
Common mistakes
- Redirecting all American requests to the English version: Googlebot, which mostly crawls from the United States, no longer sees the other versions.
- Exempting crawlers from the redirect based on their user agent: visitors are treated differently, which can be considered cloaking.
- A 301 redirect based on IP: browsers remember it, and the visitor can no longer get back to the requested version.
- A full-screen or blocking banner: it is a disguised redirect.
- A banner rendered on the server by country on a cached page: the CDN serves it to the wrong visitor, or fragments the cache by country.
- Blocking entire countries at the firewall out of caution, crawlers included.
- Forgetting a layer: the rule removed from the server still exists in the CDN or in a plugin.
Frequently asked questions
Why shouldn't you redirect visitors based on their IP address?
Google asks you not to adapt content based on IP address: geolocation is unreliable and can prevent crawling. Googlebot mostly crawls from addresses located in the United States; a country-based redirect stops it from reaching the other versions, which are then not indexed. Travelers, VPN users and people who receive a shared link are also sent to a page they did not ask for.
Can you redirect visitors but not Googlebot?
It is not recommended. Google asks you to treat Googlebot coming from a country like any other visitor from that country. An exception reserved for crawlers amounts to serving them a different behavior from users, which is akin to cloaking. AI crawlers, for their part, would not necessarily be recognized. The safe solution is to redirect no one and offer a non-blocking suggestion.
How do you suggest the right version of the site without redirecting?
Display a discreet, dismissible banner offering the equivalent page in the version for the detected country, and let the visitor click. Get the country through a small uncached request and find the equivalent URL in the page's hreflang annotations. The content stays identical for everyone, the page stays cacheable, and a language and country switcher remains visible at all times.
Are IP-based redirects legal in the European Union?
For an e-commerce site selling to customers in the European Union, Regulation (EU) 2018/302 on unjustified geo-blocking governs these practices: in principle, it prohibits redirecting customers to another version of the online interface because of their nationality or place of residence without their explicit consent. Shopify, for example, does not automatically redirect European customers on country domains. Have your case validated by a lawyer.
Resources
- Google Search Central: Managing multi-regional and multilingual sitesdevelopers.google.com
- Google Search Central: How Google crawls locale-adaptive pagesdevelopers.google.com
- EUR-Lex: Regulation (EU) 2018/302 on unjustified geo-blockingeur-lex.europa.eu
- Shopify: automatic redirection of your storehelp.shopify.com
- Cloudflare: IP geolocationdevelopers.cloudflare.com
- Amazon CloudFront: viewer location headersdocs.aws.amazon.com
- ngx_http_geoip2_module and mod_maxminddbgithub.com
Updated on
Topic checklist (PDF)