# Test multilingual dynamic routes

- Check 27.10 · Development and accessibility by language · Important
- Source: https://checklist-seo-geo.com/en/development-accessibility-language/test-multilingual-dynamic-routes
- Test the parameterized routes of each language (translated slugs, unknown codes, pagination) and fix them on Next.js, Nuxt, Laravel, Symfony or WordPress.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/development-accessibility-language/test-multilingual-dynamic-routes.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

A dynamic route is a URL pattern with parameters, such as `/{language}/blog/{slug}` or `/{language}/products/{category}/{product}`. On a multilingual site, each parameter can be wrong in several ways: unknown language code, slug from another language, untranslated segment, pagination page that does not exist. The task is to test these combinations and check that each one gets the right response: 200 in the right language, 301 to the correct URL, or 404. Once the task is done, no made-up URL returns 200.

## Why it matters

Framework routers accept any value in a parameter by default. Without an explicit check, a multilingual site produces phantom URLs:

- `/xx/tarifs/` or `/de-fr/tarifs/` return 200 with the default language's content;
- `/de/blog/nouveautes-version-4/`, a French slug under the German prefix, shows the French article with `lang="de"`;
- `/de/produits/` and `/de/produkte/` both serve the same page;
- `/en/blog/page/999/` returns an empty page with a 200.

Crawlers do not make these URLs up: they come from links badly built by the language switcher, deleted translations, old slugs or copied parameters. Once discovered, they create duplicate content, empty pages with a 200 that Google classifies as soft 404s (false 404 errors), and hreflang annotations that point to inconsistent pages. A generative engine reading one of these pages may quote French text under a German URL.

Development tests miss them, because they follow the site's correct links. You have to trigger the error cases on purpose.

## What it improves

- **Indexing**: fewer duplicate URLs and soft 404s in Search Console's page indexing report.
- **Crawl budget**: crawlers do not waste time on combinations with no content. A noticeable effect on large catalogs.
- **hreflang**: the annotations connect pages that actually exist in each language.
- **Citations in AI answers**: each text is tied to the URL of its language. Indirect effect.
- **Visitor experience**: a wrong link leads to the right page or to a helpful 404, not to an inconsistent page.

## How to check

Start with five requests on an article or product route:

```bash
for path in /de/blog/neue-funktionen/ /xx/blog/neue-funktionen/ /de/blog/nouveautes-version-4/ /DE/blog/neue-funktionen/ /de/blog/neue-funktionen-inexistant/; do
  printf '%-45s ' "$path"
  curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' "https://example.com${path}"
done
```

Expected result: `200` for the first URL, `404` for the unknown language code, `301` to the German slug for the French slug, `301` to the lowercase version (or `404`) for `/DE/`, and `404` for the slug that does not exist. Any other line returning `200` is a phantom URL.

Other checks:

- **Search Console**: "Pages" report, reasons "Soft 404", "Duplicate without user-selected canonical" and "Alternate page with proper canonical tag". Filter the examples by language prefix.
- **Crawl**: run Screaming Frog on the site and sort the 200 URLs whose `lang` attribute does not match the prefix, or whose word count is very low.
- **Server logs**: list the language codes received as the first URL segment. Unexpected values (`/es/` on a site without Spanish) reveal wrong links somewhere.

## How to implement

### Before you start

Write down the expected rule for each case, once for the whole site:

| Case | Example | Expected response |
|---|---|---|
| Correct URL | `/de/blog/neue-funktionen/` | 200, German content, `lang="de"` |
| Unknown language code | `/xx/blog/neue-funktionen/` | 404 |
| Malformed language code | `/DE/…`, `/de_DE/…` | 301 to the canonical form, or 404 |
| Slug from another language | `/de/blog/nouveautes-version-4/` | 301 to `/de/blog/neue-funktionen/` if the translation exists, otherwise 404 |
| Untranslated fixed segment | `/de/produits/` instead of `/de/produkte/` | 301 to the translated segment, or 404 |
| Slug that does not exist | `/de/blog/inexistant/` | 404 localized in German |
| Old translated slug | `/de/blog/alter-titel/` | 301 to the current slug |
| Unpublished translation | `/en/blog/draft-article/` | 404 |
| Out-of-range pagination | `/de/blog/seite/999/` | 404 |
| Language parameter in the query string | `/fr/tarifs/?lang=de` | 200 in French; the parameter does not change the language |

The case of a slug from another language depends on your architecture: if slugs are not translated, the same value is valid in every language and only the prefix matters. See [translate slugs if relevant](https://checklist-seo-geo.com/en/international-architecture/translate-slugs-if-relevant).

Turn this table into a test file, `routes.csv`, with the expected code:

```txt
/de/blog/neue-funktionen/;200
/xx/blog/neue-funktionen/;404
/de/blog/nouveautes-version-4/;301
/de/produits/;301
/de/blog/seite/999/;404
```

Then compare automatically:

```bash
#!/usr/bin/env bash
# Usage: bash test-routes.sh https://example.com routes.csv
while IFS=';' read -r path expected; do
  result=$(curl -s -o /dev/null -w '%{http_code} %{redirect_url}' "$1$path")
  code=${result%% *}

  if [ "$code" = "$expected" ]; then
    status="OK"
  else
    status="MISMATCH"
  fi

  printf '%-8s %-4s expected %-4s %s\n' "$status" "$result" "$expected" "$path"
done < "$2"
```

Plan at least one line per case and per dynamic template (article, category, product, author, tag, pagination). Add this test to your continuous integration pipeline.

### Next.js

Versions: Next.js 15.5 and 16 (App Router). The global `PageProps` and `LayoutProps` types exist from Next.js 15.5 onward.

**Unknown language.** With the App Router, reject any language outside the list in the root layout, which covers every route:

```tsx
// app/[lang]/layout.tsx
import { notFound } from 'next/navigation';

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

export const dynamicParams = false;

export async function generateStaticParams() {
  return locales.map((lang) => ({ lang }));
}

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

  if (!locales.includes(lang)) {
    notFound();
  }

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

`dynamicParams = false` returns a 404 for any parameter not generated by `generateStaticParams`. This option does not exist with Cache Components: in that case, keep the `notFound()` check.

**Slug from another language.** Look up the content in the URL's language; if it does not exist, look up the same slug in the other languages and redirect to the translation:

```tsx
// app/[lang]/blog/[slug]/page.tsx
import { notFound, permanentRedirect } from 'next/navigation';
import { findPost, findTranslationBySlug } from '@/lib/cms';

export default async function Page({ params }: PageProps<'/[lang]/blog/[slug]'>) {
  const { lang, slug } = await params;
  const post = await findPost(lang, slug);

  if (post) {
    return <article>{/* content */}</article>;
  }

  const translation = await findTranslationBySlug(slug, lang);

  if (translation) {
    permanentRedirect(`/${lang}/blog/${translation.slug}/`);
  }

  notFound();
}
```

`permanentRedirect` sends a 308 status code, which Google treats as a permanent redirect. With next-intl, translated fixed segments (`/de/produkte/`) are declared in the `pathnames` option of the routing configuration.

### Nuxt

Versions: Nuxt 4 with the @nuxtjs/i18n 10 module.

With `@nuxtjs/i18n`, language codes missing from the configuration match no prefixed route. Check the content in the page and return a real 404 error:

```vue
<!-- pages/blog/[slug].vue -->
<script setup lang="ts">
const route = useRoute();
const { locale } = useI18n();

const { data: post } = await useAsyncData(`post-${locale.value}-${route.params.slug}`, () =>
  $fetch('/api/posts', { query: { locale: locale.value, slug: route.params.slug } }),
);

if (!post.value) {
  throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true });
}
</script>
```

Translated fixed segments are declared in the page with `definePageMeta({ i18n: { paths: { de: '/produkte', en: '/products' } } })` (for a dynamic route: `'/produkte/[slug]'`). The `defineI18nRoute()` macro from previous versions is deprecated. Then test that the old untranslated segment (`/de/produits/`) no longer returns 200.

### Laravel

Versions: Laravel 11 to 13; mcamara/laravel-localization 2.x package for translated segments.

Constrain the language parameter at the route group level:

```php
// routes/web.php
Route::prefix('{locale}')
    ->where(['locale' => 'fr|de|en'])
    ->middleware(SetLocale::class)
    ->group(function (): void {
        Route::get('/blog/{slug}', [PostsController::class, 'show'])->name('posts.show');
    });
```

A language outside the list matches no route: Laravel returns 404. In the controller, look up the slug in the current language, then redirect to the translation if the slug belongs to another language:

```php
// app/Http/Controllers/PostsController.php
public function show(string $locale, string $slug): View|RedirectResponse
{
    $post = Post::query()
        ->where('locale', $locale)
        ->where('slug', $slug)
        ->first();

    if ($post) {
        return view('posts.show', ['post' => $post]);
    }

    $translation = Post::query()
        ->where('slug', $slug)
        ->first()
        ?->translationIn($locale);

    if (! $translation) {
        abort(404);
    }

    return redirect()->route('posts.show', ['locale' => $locale, 'slug' => $translation->slug], 301);
}
```

You write `translationIn()` to suit your translation model. With the Laravel Localization package (mcamara), translated fixed segments go through its translated routes (`LaravelLocalization::transRoute()`): test that the old segment returns 404 or 301.

### Symfony

Versions: Symfony 6.4, 7.4 and 8.x.

Restrict `_locale` and let the controller return a 404:

```php
// src/Controller/PostsController.php
#[Route('/{_locale}/blog/{slug}', name: 'post_show', requirements: ['_locale' => 'fr|de|en'])]
public function show(string $_locale, string $slug, PostRepository $posts): Response
{
    $post = $posts->findOneBy(['locale' => $_locale, 'slug' => $slug]);

    if (! $post) {
        throw $this->createNotFoundException();
    }

    return $this->render('post/show.html.twig', ['post' => $post]);
}
```

Translated fixed segments are declared with per-language paths: `#[Route(path: ['fr' => '/produits', 'de' => '/produkte'], name: 'products')]`.

### WordPress

Versions: WordPress 6.8 to 7.1, with WPML 4.8 and 4.9 or Polylang 3.x.

WPML and Polylang handle the language prefix and the slugs of each translation. Three behaviors to test:

- **Unknown prefix**: `/xx/my-article/` must return 404. Depending on the configuration, WordPress may interpret `xx` as a parent page or a category.
- **Slug from another language**: WordPress can redirect a URL it cannot find to a post with a similar slug, including in another language. This guessing is turned off in the child theme's `functions.php` or in a custom plugin:

```php
add_filter('do_redirect_guess_404_permalink', '__return_false');
```

- **Identical slugs across languages**: Polylang can allow the same slug in several languages; check that each prefix really shows its own translation.

Redirect plugins (Redirection, Yoast SEO Premium, Rank Math) are then used to redirect old translated slugs. Purge the page cache before running the tests again.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Shopify alone manages the markets' language prefixes and translated handles. You cannot change the routing, but you can test: an unpublished language prefix, a deleted translated handle, a handle in the original language under a translated prefix. For old handles, create URL redirects from the admin: `Content > Menus`, then "View URL redirects" and "Create URL redirect"; check the result with the script, on each language prefix.

## Common mistakes

- **Accepting any value in `[lang]`**: each made-up code creates a full copy of the site returning 200.
- **Rendering the default content when the translation is missing**: French text under a German URL, with a 200 status code.
- **Redirecting every unknown URL to the language's home page**: Google treats these redirects as soft 404s.
- **Letting the `?lang=` parameter change a URL's language**: two languages under the same base URL.
- **Forgetting pagination and filters**: `/de/blog/seite/999/` returns 200 with an empty list.
- **Building the switcher's links by replacing only the prefix**: `/de/blog/nouveautes-version-4/` instead of the translated slug. See [link to the equivalent page rather than the homepage](https://checklist-seo-geo.com/en/international-architecture/link-equivalent-page-rather-than-homepage).
- **Returning a "not found" page with a 200 status code**: the template shows the message, but the status code stays 200.

## Frequently asked questions

### Should a URL with an unknown language code return a 404 error?

Yes. A URL such as /xx/tarifs/ that returns 200 with the default language's content creates a copy of the site under a made-up prefix, which Google may crawl and classify as a duplicate or a soft 404. Limit the language parameter to the list of published languages, at the router level, and return a real 404 for any other value, including malformed variants.

### What should you do when one language's slug is used under another language's prefix?

If the page exists in the prefix's language, redirect with a 301 to its translated slug: the visitor lands on the right page and the wrong link keeps its value. If no translation exists, return a localized 404. Never show the other language's content under that URL: the text, the lang attribute and the hreflang annotations would become inconsistent.

### How do you test thousands of multilingual dynamic routes?

Test a sample: for each template and each language, one valid URL and one URL for each error case (unknown language, slug from another language, slug that does not exist, out-of-range pagination). A broken rule is broken for every URL of the template. Add a full crawl, which finds valid URLs returning errors, and Search Console's indexing report.

### Should a deleted translation return a 404 or a 410?

Both work. Google treats 404 and 410 status codes very similarly: the URL eventually drops out of the index. A 410 explicitly signals a permanent removal. If the page still exists in another language, a redirect to it only helps if it meets the same need. In every case, remove the deleted URL from the hreflang annotations and the sitemap.

## Resources

- [Google Search Central: How HTTP status codes, and network and DNS errors affect Google Search](https://developers.google.com/search/docs/crawling-indexing/http-network-errors?hl=en)
- [Google Search Central: Soft 404 errors](https://developers.google.com/search/docs/crawling-indexing/http-network-errors?hl=en#soft-404-errors)
- [Next.js: generateStaticParams and dynamicParams](https://nextjs.org/docs/app/api-reference/functions/generate-static-params)
- [Nuxt i18n: Custom route paths](https://i18n.nuxtjs.org/docs/guide/custom-paths)
- [Laravel: Regular expression constraints on route parameters](https://laravel.com/docs/routing#parameters-regular-expression-constraints)
- [Symfony: Localized routes](https://symfony.com/doc/current/routing.html#localized-routes-i18n)
- [WordPress: do_redirect_guess_404_permalink filter](https://developer.wordpress.org/reference/hooks/do_redirect_guess_404_permalink/)

Next steps: [check localized 404 errors](https://checklist-seo-geo.com/en/multilingual-indexing-sitemaps/check-localized-404-errors), [check redirects and old translated URLs](https://checklist-seo-geo.com/en/multilingual-indexing-sitemaps/check-redirects-old-translated-urls) and [serve the right content at the requested URL](https://checklist-seo-geo.com/en/development-accessibility-language/serve-right-content-at-requested-url).
