Check 22.05 · International architecture

Plan a separate URL for each language version

Give each language version its own URL, with no parameter, cookie or language negotiation, on Apache, Nginx, Cloudflare, WordPress, Shopify, Laravel, Next.js.

Priority
Critical
Difficulty
Intermediate
Estimated time
2 h to 2 days
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

Each language version of a page must have its own address, which always returns the same language to everyone: example.com/fr/tarifs/ in French, example.com/de/preise/ in German. No language chosen by a parameter, a cookie, the Accept-Language header or a #fr fragment. Once the task is done, every URL returns 200 in a single language, whatever client requests it.

Why it matters

Google explicitly recommends using different URLs for each language version, rather than cookies or browser settings. It explains why: Googlebot usually crawls from the United States and does not send an Accept-Language header. If the same URL changes language depending on the visitor, the crawler sees only one version, usually the default one, and the others are never indexed.

hreflang annotations rest on the same principle: they connect URLs to each other. Without distinct URLs, there is nothing to annotate, and Google cannot show the right version in search results.

Generative engine crawlers are in the same situation. They request a URL and read the response; those that do not execute JavaScript only see the initial HTML. A page that only becomes German after a click or a script remains French to them, and cannot be cited in German.

Fragments solve nothing: Google states that it generally does not support URL fragments to distinguish content, and the fragment is never sent to the server.

What it improves

  • Indexing of each language Each version can be crawled, indexed and ranked separately.
  • hreflang Only possible between distinct URLs.
  • Citations in AI answers Each version is a citable source in its own language. Effect not guaranteed.
  • Sharing and links A link sent to a colleague opens the intended language, not the one in their browser.
  • Caching One URL, one response; CDNs cache without complex variation.
  • Measurement Traffic and conversions can be segmented by URL prefix.

How to check

Request the same URL while changing the announced language, without a cookie, and compare the response fingerprints:

for lang in "" "fr" "de" "en-US"; do
  curl -s -H "Accept-Language: ${lang}" https://example.com/fr/tarifs/ | md5
done

On Linux, replace md5 with md5sum. Expected result: four identical fingerprints (apart from dynamic elements such as a form token). If they differ, the page changes its content depending on the visitor.

Also check the language actually served at each URL:

curl -s https://example.com/de/preise/ | grep -o -i '<html[^>]*lang="[^"]*"'

Other checks:

  • Search Console: inspect one URL for each language and open the crawled page. The HTML must be in the URL's language.
  • Crawl: with Screaming Frog, crawl without cookies; each language must appear under its own URLs. Finding only one language points to a switcher that does not link to distinct URLs.
  • Parameters: search for ?lang=, ?locale= or ?hl= in the crawled URLs and in the sitemap.

How to implement

Before you start

Rules that apply everywhere:

Apache

Versions Apache 2.4.

The language prefix is handled by the application. At server level, what remains is redirecting the old parameter URLs. In the .htaccess file at the root:

RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)lang=(fr|de|en)(&|$) [NC]
RewriteRule ^(.*)$ /%2/$1? [R=301,L]

%2 reuses the captured language code, $1 the path, and the trailing ? removes the query string. In a virtual host, the path starts with a slash: write RewriteRule ^/(.*)$ /%2/$1? [R=301,L]. This rule works if slugs are identical in every language; with translated slugs (opens in a new tab), use a lookup table (see Nginx) or handle the redirect in the application.

sudo apachectl configtest && sudo systemctl reload apache2

Nginx

Versions Nginx 1.24 and later.

Simple redirect, identical slugs, in the server block:

location / {
    if ($arg_lang ~* ^(fr|de|en)$) {
        return 301 /$arg_lang$uri;
    }
    try_files $uri $uri/ /index.php?$query_string;
}

With translated slugs, a lookup table in the http context:

map $request_uri $lang_redirect {
    default "";
    "/tarifs?lang=de" /de/preise/;
    "/tarifs?lang=en" /en/pricing/;
    "/contact?lang=de" /de/kontakt/;
}

server {
    # in the site's existing server block
    if ($lang_redirect) {
        return 301 $lang_redirect;
    }
}
sudo nginx -t && sudo systemctl reload nginx

Cloudflare

Versions Cloudflare dashboard, Redirect Rules, all plans, November 2026.

A language in the URL requires no special cache setting. Just check that no rule varies the cache by a language cookie or the Accept-Language header.

To redirect old parameter URLs without touching the server, create a redirect rule: Rules > Redirect Rules from the Rules Overview, one rule per language.

  • Expression: (http.request.uri.query contains "lang=de")
  • URL type: Dynamic, expression concat("/de", http.request.uri.path)
  • Status code: 301, query string not preserved.

Test with curl -sI "https://example.com/tarifs?lang=de": the response must be 301 with location: https://example.com/de/tarifs.

AWS

Versions AWS console, Amazon CloudFront and CloudFront Functions (JavaScript runtime 2.0), November 2026.

On CloudFront, since the language is in the path, do not add Accept-Language to the cache key: each URL already has its own response. To redirect old parameter URLs at the edge, associate a CloudFront Function with the "Viewer request" event:

function handler(event) {
  var request = event.request;
  var lang = request.querystring.lang;
  var allowed = ['fr', 'de', 'en'];

  if (lang && allowed.indexOf(lang.value) !== -1) {
    return {
      statusCode: 301,
      statusDescription: 'Moved Permanently',
      headers: {
        location: { value: '/' + lang.value + request.uri },
      },
    };
  }

  return request;
}

Publish the function, associate it with the relevant behavior, then invalidate /*. On S3 alone, create one folder per language (fr/, de/): each file then has its own URL.

WordPress

Versions WordPress 6.8 and later; WPML 5 and Polylang 3, November 2026.

  • WPML: if the URL format is the parameter (?lang=fr), switch to directories in WPML > Settings > URLs and SEO (Language URL format section). Then check that the old parameter URLs redirect to the new ones; if not, add the Apache or Nginx rule above.
  • Polylang: in Languages > Settings, URL modifications module, choose the option where the language is set from the directory name. The mode where the language is set from the content adds no language code to the URL: in that case, check that the homepage and archives of each language do have their own address.
  • Browser-side translation plugins (JavaScript machine translation widgets): they create no URLs. Replace them with a plugin that publishes translated pages under their own URLs.

Check that the caching plugin does not serve one URL in several languages: purge the whole cache after the change.

Shopify

Versions Shopify, all plans, Shopify Markets, November 2026.

Each published language gets its own URLs. For international markets, give each one a subfolder (/fr-ca) or a domain: Shopify states that the content of markets served on a shared domain, without their own URL, is not indexed. Configure it in Markets, in the market's domain management. Shopify then adds the hreflang annotations automatically.

Laravel

Versions Laravel 11 to 13.

Put the language in a route prefix and set it in a middleware, never from the session alone:

// app/Http/Middleware/SetLocale.php
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\URL;
use Symfony\Component\HttpFoundation\Response;

class SetLocale
{
    public function handle(Request $request, Closure $next): Response
    {
        $locale = $request->route('locale');

        App::setLocale($locale);

        URL::defaults(['locale' => $locale]);

        $request->route()->forgetParameter('locale');

        return $next($request);
    }
}
// routes/web.php
use App\Http\Controllers\PagesController;
use App\Http\Middleware\SetLocale;
use Illuminate\Support\Facades\Route;

Route::prefix('{locale}')
    ->where(['locale' => 'fr|de|en'])
    ->middleware(SetLocale::class)
    ->group(function () {
        Route::get('/', [PagesController::class, 'home'])->name('home');
    });

URL::defaults() fills in the locale parameter in route('home'); forgetParameter() avoids passing it to controllers. The Laravel Localization package (mcamara) provides a ready-made equivalent.

Symfony

Versions Symfony 6.4, 7 and 8.

A per-language prefix on all controller routes, in config/routes.yaml:

controllers:
    resource: routing.controllers
    prefix:
        fr: ''
        de: '/de'
        en: '/en'

resource: routing.controllers is the form introduced in Symfony 7.4: it loads #[Route] attributes wherever they are in the application. In a Symfony 6.4 to 7.3 project, the existing import is written resource: { path: ../src/Controller/, namespace: App\Controller } with type: attribute: add the same prefix key to it. Symfony creates one route per language and sets _locale automatically. Clear the cache: php bin/console cache:clear.

Next.js

Versions Next.js 15.5 and 16, App Router and Pages Router.

Whichever router you use, do not serve several languages under an unprefixed URL based on a cookie.

App Router

Put all pages under app/[lang]/ and generate each language:

// app/[lang]/layout.tsx
export async function generateStaticParams() {
  return [{ lang: 'fr' }, { lang: 'de' }, { lang: 'en' }];
}

export default async function RootLayout({ children, params }: LayoutProps<'/[lang]'>) {
  const { lang } = await params;

  return (
    <html lang={lang}>
      <body>{children}</body>
    </html>
  );
}

The global LayoutProps type has been available since Next.js 15.5; on an earlier version, type params as Promise<{ lang: string }>.

Pages Router

The built-in i18n routing, available only in the Pages Router, creates the prefixes (/de/blog):

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

localeDetection: false prevents automatic redirection based on the Accept-Language header: each URL keeps its language. The default language is served without a prefix (/blog), the others under their own (/de/blog). Restart the development server or run next build again after the change.

Nuxt

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

With the @nuxtjs/i18n module, choose a prefix strategy:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxtjs/i18n'],
  i18n: {
    baseUrl: 'https://example.com',
    defaultLocale: 'fr',
    strategy: 'prefix_except_default',
    detectBrowserLanguage: false,
    locales: [
      { code: 'fr', language: 'fr-FR' },
      { code: 'de', language: 'de-DE' },
      { code: 'en', language: 'en' },
    ],
  },
});

The no_prefix strategy serves every language under the same URLs: avoid it for a public site.

Astro

Versions Astro 5 to 7.

// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  site: 'https://example.com',
  i18n: {
    locales: ['fr', 'de', 'en'],
    defaultLocale: 'fr',
    routing: {
      prefixDefaultLocale: false,
    },
  },
});

Put the translated pages in src/pages/de/ and src/pages/en/: each file becomes a distinct URL.

Common mistakes

  • Language chosen by cookie or session on a single URL: Googlebot, being stateless, only sees the default language.
  • Negotiation through Accept-Language on the same URL: Googlebot does not send this header.
  • A ?lang= parameter kept alongside the new URLs, without a redirect: duplicates and scattered links.
  • A #de fragment to switch language: never sent to the server, ignored for indexing.
  • Default language reachable under two URLs (/ and /fr/) with no redirect or canonical.
  • A shared cache that ignores the language when it depends on a cookie: one visitor receives the previous visitor's language.
  • A switcher that changes the language with JavaScript without changing the URL.

Frequently asked questions

Why does Google recommend a different URL for each language?

Googlebot usually crawls from the United States, does not send an Accept-Language header and does not keep cookies from one page to the next. If the same URL changes language depending on the visitor, it sees only one, usually the default version, and the others are not indexed. A distinct URL for each language makes it possible to crawl, index and connect every version with hreflang.

Is a ?lang=fr parameter enough to have distinct URLs?

Technically, these are different URLs, but Google advises against parameters to separate versions: segmentation is difficult, targeting is unclear and duplicates are common when the parameter is ignored or combined with others. Prefer a subdirectory such as /fr/, a subdomain or a country-code domain, and redirect the old parameter URLs to their new equivalent with a 301 redirect.

Can you serve the browser language on the homepage?

Avoid changing the homepage content according to the browser language under a single URL: Googlebot does not send that header and would see only one version. If the root must guide visitors, make it a language selection page annotated x-default, or display a suggestion without a forced redirect. Each language thus keeps its own indexable homepage.

Do you need distinct URLs if the site is translated with JavaScript?

Yes. A translation applied in the browser by JavaScript creates no page that search engines can index: Googlebot would at best see the initial language, and most generative engine crawlers do not execute JavaScript. Publish each language under its own URL, with the translated content in the HTML returned by the server.

Updated on

Topic checklist (PDF)

And now?

In the “International architecture” topic

  1. Define target languages
  2. Define target countries
  3. Distinguish language from geotargeting
  4. Choose subdirectories, subdomains or country-code domains
  5. Plan a separate URL for each language version
  6. Translate slugs if relevant
  7. Avoid handling language only through cookies/JS
  8. Avoid forced IP-based redirects
  9. Avoid forced redirects based on browser language
  10. Provide a crawlable language switcher
  11. Link to the equivalent page rather than the homepage
  12. Plan for missing translations
  13. Check URL structure consistency
  14. Define the default version
  15. Avoid mixed-language pages with partial translations