# Avoid forced redirects based on browser language

- Check 22.09 · International architecture · Critical
- Source: https://checklist-seo-geo.com/en/international-architecture/avoid-forced-redirects-based-browser-language
- Remove automatic redirects based on browser language and suggest the right version without forcing it, on the server, CDN, CMS or framework.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/international-architecture/avoid-forced-redirects-based-browser-language.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

A multilingual site must not automatically send a visitor to another language because their browser announces `Accept-Language: de`. Every URL returns 200 in its own language, for everyone. Once this task is done, the browser language is used at most to display a suggestion (“This page is available in German”), and only the root `/` may direct the visitor.

## Why it matters

With every request, the browser sends the `Accept-Language` header, which reflects the system language or the user's preferences. Many sites, plugins and frameworks use it to redirect: a German visitor who opens `example.com/fr/tarifs/` is sent to `example.com/de/preise/`.

Google asks you to avoid this practice: its documentation on multilingual sites recommends not redirecting a user automatically from one language version to another. It also points out that Googlebot usually crawls from the United States and sends its requests without an `Accept-Language` header. If the site redirects based on language, the crawler only sees the default version, and Google warns that it may not find or crawl all the variants.

Visitors suffer just as much:

- an expatriate whose browser is set to English can no longer read the French version they searched for;
- a shared link or a search result clicked in one language leads to another;
- a visitor who chooses a language in the switcher is sent to another one, sometimes in a loop.

Generative engine crawlers face the same problem: nothing guarantees that they announce a language. A page that redirects based on the client can be read, summarized and cited in a language other than that of its URL.

## What it improves

- **Indexing of every language**: all versions remain accessible to crawlers, which no longer systematically receive the default version.
- **hreflang**: the annotations only work if every target URL returns 200 without a redirect.
- **Visitor experience**: the page requested is the page displayed; the language choice is respected.
- **Citations in AI answers**: each version can be read and cited under its own URL. A possible effect, never guaranteed.
- **Caching**: with no variation on `Accept-Language`, a CDN caches a single response per URL.
- **Rankings**: no direct effect; the gain comes from the correct indexing of the versions.

## How to check

Request the same URL while announcing several languages, without following redirects:

```bash
for lang in "" "de-DE,de;q=0.9" "en-US,en;q=0.8" "es-ES,es;q=0.9"; do
  printf '%-18s ' "${lang:-none}"
  curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' -H "Accept-Language: ${lang}" https://example.com/fr/tarifs/
done
```

Expected result: four `200` lines with no redirect URL. A `301`, `302` or `307` line pointing to another language signals a forced redirect. Repeat the test on a deep page of each language and on the root `/`.

The redirect can also be done in JavaScript, after the page loads. Look for reads of the browser language in the HTML and the scripts:

```bash
curl -s https://example.com/fr/tarifs/ | grep -o -E "navigator\.(language|languages)|window\.location(\.href)? *="
```

Other checks:

- **Browser**: set the browser's preferred language to German, open a private window, then a French URL. It must stay in French.
- **Search Console**: the URL Inspection tool shows the page as Googlebot sees it; a German URL that displays French content, or a reported redirect, gives the problem away.
- **`Vary` header**: `curl -sI https://example.com/fr/tarifs/ | grep -i vary`. `Accept-Language` on an inner page indicates that the content or the response changes with the announced language.

## How to implement

### Before you start

Target behavior:

| URL requested | Expected response | Use of the browser language |
|---|---|---|
| Inner page (`/fr/tarifs/`, `/de/preise/`) | 200, always in the URL's language | Optional suggestion, never a redirect |
| Root without a language (`/`) | 200 on a language selection page or the default language (recommended), or 302 to a language (tolerated) | Possible, with `Vary: Accept-Language` and an `x-default` annotation |
| URL requested after a choice in the switcher | 200 on the chosen language | Ignored |

Google mentions homepages that redirect based on language in its documentation on `x-default`: it is the only case where automatic routing remains defensible. If you keep it, use a temporary redirect (302), never a 301: a 301 can be cached by the browser and treated as permanent. See [define the default version](https://checklist-seo-geo.com/en/international-architecture/define-default-version).

Start by finding where the current redirects come from: server configuration, CDN rule, CMS plugin, framework middleware or JavaScript. The same redirect can come from several layers.

### Replace the redirect with a suggestion

A non-blocking banner offers the version in the browser's language, without forcing anything. This script reads the `hreflang` annotations already present in the `<head>` to find the equivalent page, and remembers when the banner is closed:

```html
<div id="lang-suggestion" hidden>
  <a id="lang-suggestion-link" href="#"></a>
  <button type="button" id="lang-suggestion-close" aria-label="Close">×</button>
</div>

<script>
  (function () {
    var labels = { fr: 'Voir cette page en français', de: 'Diese Seite auf Deutsch ansehen', en: 'View this page in English' };
    var current = document.documentElement.lang.slice(0, 2).toLowerCase();
    var alternates = {};

    try {
      if (localStorage.getItem('lang-suggestion-closed')) {
        return;
      }
    } catch (error) {}

    document.querySelectorAll('link[rel="alternate"][hreflang]').forEach(function (link) {
      alternates[link.hreflang.slice(0, 2).toLowerCase()] = link.href;
    });

    var preferred = (navigator.languages || [navigator.language]).map(function (lang) {
      return lang.slice(0, 2).toLowerCase();
    }).find(function (lang) {
      return alternates[lang] && labels[lang];
    });

    if (!preferred || preferred === current) {
      return;
    }

    var banner = document.getElementById('lang-suggestion');
    var link = document.getElementById('lang-suggestion-link');

    link.href = alternates[preferred];
    link.textContent = labels[preferred];
    link.lang = preferred;
    link.hreflang = preferred;
    banner.hidden = false;

    document.getElementById('lang-suggestion-close').addEventListener('click', function () {
      banner.hidden = true;

      try {
        localStorage.setItem('lang-suggestion-closed', '1');
      } catch (error) {}
    });
  })();
</script>
```

The page content does not change: Googlebot and the crawlers that do not run JavaScript see the same page as everyone else. Place the banner at the top of the page without shifting the content (reserve its height or display it as an overlay) so as not to degrade CLS.

### Apache

Versions: Apache 2.4.

Look for existing rules:

```bash
grep -rn -i "accept-language" /etc/apache2/ /etc/httpd/ /var/www/ 2>/dev/null
```

A rule like `RewriteCond %{HTTP:Accept-Language} ^de` followed by a `RewriteRule ^(.*)$ /de/$1` redirects every page: remove it. If you want to keep routing on the root only, replace it with this block in the `.htaccess` file:

```apache
RewriteEngine On

RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^$ /de/ [R=302,L]

RewriteCond %{HTTP:Accept-Language} ^en [NC]
RewriteRule ^$ /en/ [R=302,L]

RewriteRule ^$ /fr/ [R=302,L]

<If "%{REQUEST_URI} == '/'">
    Header always merge Vary "Accept-Language"
</If>
```

In a `.htaccess` file, `^$` only matches the root; in a virtual host, write `^/$`. `always` is needed for the header to accompany the 302 response. Reload with `sudo apachectl configtest && sudo systemctl reload apache2`.

### Nginx

Versions: Nginx 1.24 and later.

Look for `$http_accept_language` in `/etc/nginx/`. Remove any redirect that applies to `location /` or to content paths. A version limited to the root, with a map in the `http` context:

```nginx
map $http_accept_language $preferred_lang {
    default fr;
    ~*^de   de;
    ~*^en   en;
}
```

And in the `server` block:

```nginx
location = / {
    add_header Vary "Accept-Language" always;
    return 302 /$preferred_lang/;
}
```

The map only looks at the first language announced, which is enough in the vast majority of cases. Reload with `sudo nginx -t && sudo systemctl reload nginx`.

### Shared hosting

Language redirects almost always come from the `.htaccess` file or a CMS plugin. Open the `.htaccess` file at the root from the control panel's file manager (cPanel, Plesk or the host's interface), search for `Accept-Language`, then apply the Apache section. If nothing turns up, the redirect comes from the application: see the CMS and framework sections.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Cloudflare does not redirect based on language by default. A redirect of this kind comes from a rule or a Worker added to the account. Open the [rules overview](https://dash.cloudflare.com/?to=/:account/:zone/rules/overview) and look for expressions that use `http.request.headers["accept-language"]`, then check the Workers and Snippets attached to the domain's routes.

To limit routing to the root, use one redirect rule (`Rules > Redirect Rules`) per language:

- Expression: `(http.request.uri.path eq "/" and starts_with(http.request.headers["accept-language"][0], "de"))`
- Static URL: `https://example.com/de/`
- Status code: 302.

Add a last rule for the default language, with the expression `(http.request.uri.path eq "/")`. If a Cache Rule caches the HTML, exclude `/`: otherwise the first response served to one visitor could be served to everyone.

### AWS

Versions: Amazon CloudFront, CloudFront Functions (JavaScript runtimes 1.0 and 2.0), AWS console, November 2026.

On **CloudFront**, language redirects go through a CloudFront Function or a Lambda@Edge function. Open the [CloudFront console](https://console.aws.amazon.com/cloudfront/v4/home), `Functions` section, and check those associated with the distribution's behaviors. Limit the redirect to the root:

```js
function handler(event) {
  var request = event.request;

  if (request.uri !== '/') {
    return request;
  }

  var header = request.headers['accept-language'];
  var value = header ? header.value.toLowerCase() : '';
  var lang = 'fr';

  if (value.indexOf('de') === 0) {
    lang = 'de';
  }

  if (value.indexOf('en') === 0) {
    lang = 'en';
  }

  return {
    statusCode: 302,
    statusDescription: 'Found',
    headers: {
      location: { value: '/' + lang + '/' },
      vary: { value: 'Accept-Language' },
      'cache-control': { value: 'private, no-store' },
    },
  };
}
```

Associate it with the “Viewer request” event: it runs before the cache, which therefore does not need to include `Accept-Language` in its key. Publish the function, then test with the `curl` loop from the “How to check” section.

### Vercel

Versions: Vercel dashboard and `vercel.json` file, all plans, November 2026.

Vercel does not redirect based on language without configuration. In `vercel.json`, look for `redirects` entries with a `has` condition on the `accept-language` header, and limit them to the `/` source. With Next.js, see the dedicated section.

### Netlify

Versions: Netlify `_redirects` file, all plans, November 2026.

Netlify can redirect based on language in the `_redirects` file, with the `Language=` condition. These rules must only target the root:

```txt
/  /de/  302!  Language=de
/  /en/  302!  Language=en
/  /fr/  302!
```

The `!` forces the rule even if an `index.html` file exists at the root. Netlify compares the first language of the `Accept-Language` header and lets you override it with an `nf_lang` cookie, which your switcher can set. Remove any `Language=` rule on a content path, such as `/*` or `/produits/*`.

### WordPress

Versions: WordPress 6.8 to 7.1; WPML 5.3 and later (earlier versions noted), Polylang 3.x, TranslatePress 3.x.

- **WPML**: since WPML 5.3, the setting is in `WPML > Settings`, `URLs and SEO` tab, “Visitor language” section. For new visitors, choose to keep them on the page they opened (the default setting), or to show a bar that offers the page in their language, rather than the automatic redirect. In earlier versions, the section is called “Browser language redirect” and only offers redirect options: disable it. WPML's own documentation points out that the redirect can affect indexing by Google.
- **Polylang**: in `Languages > Settings`, disable browser language detection. Polylang only applies it to the homepage and remembers the last language in a cookie; its documentation states that to remove all redirects, you must also hide the default language code in URLs (“URL modifications” module).
- **TranslatePress**: the automatic language detection add-on displays a suggestion pop-up or bar; direct redirection is marked as deprecated there. Keep the suggestion.
- **Theme or custom code**: search for `HTTP_ACCEPT_LANGUAGE` in `wp-content` (`grep -rn HTTP_ACCEPT_LANGUAGE wp-content/`) and remove the redirects you find.

Then purge the page cache, which may have kept redirects.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Shopify offers automatic redirection based on browser language. To turn it off: `Online Store > Preferences`, `Automatic redirection` section, turn off the `Language` option, then save. The `Country/region` option is IP-based redirection: see [avoid forced IP-based redirects](https://checklist-seo-geo.com/en/international-architecture/avoid-forced-ip-based-redirects). Shopify does not document how these redirects treat crawlers; by turning them off, you let the `hreflang` annotations that Shopify generates do the work.

Also check the geolocation or translation apps installed: some add their own redirect.

### Laravel

Versions: Laravel 10 to 13; mcamara/laravel-localization 2.x package.

With the Laravel Localization package (mcamara), set `config/laravellocalization.php`:

```php
'useAcceptLanguageHeader' => false,

'hideDefaultLocaleInURL' => false,
```

The `localeSessionRedirect` and `localeCookieRedirect` middlewares redirect URLs without a language prefix based on the session, the cookie or the browser. With `hideDefaultLocaleInURL` set to `true`, the default language's pages have no prefix and would therefore be redirected: do not use these middlewares in that configuration.

Without a package, route only the root, in an invokable controller:

```php
// app/Http/Controllers/PreferredLocaleRedirectController.php
namespace App\Http\Controllers;

use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

class PreferredLocaleRedirectController
{
    public function __invoke(Request $request): RedirectResponse
    {
        $locale = $request->getPreferredLanguage(['fr', 'de', 'en']);

        return redirect("/{$locale}/", 302)->header('Vary', 'Accept-Language');
    }
}
```

```php
// routes/web.php
Route::get('/', PreferredLocaleRedirectController::class)->name('home');
```

`getPreferredLanguage()` returns the first language in the list when the browser announces none that matches: Googlebot therefore gets the default language.

### Next.js

Versions: Next.js 15 and 16.

#### App Router

Detection is coded in `proxy.ts` (on Next.js 15: `middleware.ts` file and exported `middleware` function). The documentation's example redirects every URL without a prefix; limit it to the root with the `matcher`:

```ts
// proxy.ts
import { NextRequest, NextResponse } from 'next/server';

const locales = ['fr', 'de', 'en'];

export function proxy(request: NextRequest) {
  const header = request.headers.get('accept-language') ?? '';
  const preferred = header.slice(0, 2).toLowerCase();
  const locale = locales.includes(preferred) ? preferred : 'fr';

  const response = NextResponse.redirect(new URL(`/${locale}`, request.url), 302);
  response.headers.set('Vary', 'Accept-Language');

  return response;
}

export const config = {
  matcher: ['/'],
};
```

#### Pages Router

The `i18n` configuration detects the language on the root and redirects to `/fr` or to the language's domain. Disable it:

```js
// next.config.js
module.exports = {
  i18n: {
    locales: ['fr', 'de', 'en'],
    defaultLocale: 'fr',
    localeDetection: false,
  },
};
```

### Nuxt

Versions: Nuxt 3.x and 4, @nuxtjs/i18n module 9 and 10.

The `@nuxtjs/i18n` module enables browser language detection by default, limited to the root. To remove it:

```ts
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxtjs/i18n'],
  i18n: {
    detectBrowserLanguage: false,
  },
});
```

To keep routing on the root, keep `redirectOn: 'root'`, which the module's documentation recommends for SEO, and do not enable `alwaysRedirect`.

### Astro

Versions: Astro 5 to 7.

Astro never redirects based on browser language. With server rendering, `Astro.preferredLocale` gives the preferred language among those of the site: use it to display a suggestion, not to redirect.

## Common mistakes

- **Redirecting every page based on `Accept-Language`**: Googlebot, which does not send this header, only sees the default language.
- **Using a 301 to route the root**: the browser caches it and the visitor can no longer return to `/`.
- **Redirecting in JavaScript after the page loads**: the problem is the same for visitors, and Google follows JavaScript redirects.
- **Ignoring the visitor's explicit choice**: they click “English” and the redirect sends them back to German.
- **Caching a response that depends on language** without `Vary: Accept-Language`: one visitor receives the redirect meant for another.
- **Stacking layers**: a WordPress plugin, a Cloudflare rule and the `.htaccess` file each redirect on their own.
- **Displaying a blocking modal** instead of the redirect: it gets in the way of reading and can hide the content.

## Frequently asked questions

### Can you redirect a visitor based on their browser language?

Avoid it on content pages. Google recommends not redirecting automatically from one language version to another: Googlebot crawls without an Accept-Language header and would only see the default version, and the visitor loses the page they requested. Only the root without a language may route the visitor, with a 302 redirect annotated as x-default. Elsewhere, display a non-blocking suggestion.

### Is a language redirect on the homepage acceptable?

It is the only defensible case. Google mentions homepages that redirect based on language in its documentation on x-default. Use a temporary 302 redirect, add the Vary: Accept-Language header, and declare the root as x-default in the hreflang annotations. A language selection page, or the default language served directly on the root, remains preferable, because neither forces anything.

### How can you suggest the right language without a forced redirect?

Display a discreet banner at the top of the page that offers the equivalent page in the browser's language, with a link and a close button. The page content does not change, Googlebot sees the same page as everyone else, and the visitor keeps the choice. Remember when the banner is closed so that it does not reappear on every page.

### How can I tell whether my site redirects based on browser language?

Request an inner page with curl while changing the Accept-Language header, without following redirects. If the response changes from 200 to 301, 302 or 307 pointing to another language, the redirect exists. Also check the JavaScript code, which can read navigator.language and change pages after loading, then test with a browser set to another language, in a private window.

## Resources

- [Google Search Central: Managing multi-regional and multilingual sites](https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites?hl=en)
- [Google Search Central: Localized versions and x-default](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=en)
- [W3C: Is language negotiation a good idea?](https://www.w3.org/International/questions/qa-site-conneg)
- [WPML: Browser language redirect](https://wpml.org/documentation/getting-started-guide/language-setup/automatic-redirect-based-on-browser-language/)
- [Polylang: Detect the browser preferred language](https://polylang.pro/documentation/support/guides/detect-the-browser-preferred-language/)
- [Shopify: Automatic redirection](https://help.shopify.com/en/manual/international/automatic-redirection)
- [Next.js: Internationalization (Pages Router)](https://nextjs.org/docs/pages/guides/internationalization) and [App Router](https://nextjs.org/docs/app/guides/internationalization)
- [Nuxt i18n: Browser language detection](https://i18n.nuxtjs.org/docs/guide/browser-language-detection)
- [Netlify: Redirects by country or language](https://docs.netlify.com/manage/routing/redirects/redirect-options/)

Next steps: [provide a crawlable language switcher](https://checklist-seo-geo.com/en/international-architecture/provide-crawlable-language-switcher), [define the default version](https://checklist-seo-geo.com/en/international-architecture/define-default-version) and [test without Accept-Language](https://checklist-seo-geo.com/en/development-accessibility-language/test-without-accept-language).
