In short
A non-existent URL under /de/ must respond with the HTTP status code 404 and display an error page in German, with links to the German sections. On many multilingual sites, this is not the case: the 404 is displayed in the default language, returns a 200 status code, or redirects to the home page. The task is to test non-existent URLs for each language and each template, then fix the server or the application. Once this is done, each language has its own 404, in its language, with the right status code.
Why it matters
The HTTP status code is what search engines read. Google does not index URLs that respond with a 4xx and eventually removes those that were indexed. Conversely, a “not found” page served with a 200 is treated as a soft 404: it uses up crawling, clutters the reports and can stay in the index for a while. A blanket redirect to the home page is often classified the same way.
On a multilingual site, three further defects come into play:
- The 404 in the wrong language. The application often determines the language after finding the route. When the route does not exist, the language is never set and the error page comes out in the default language, with a wrong
<html lang>. - Different status codes depending on the language. The French version responds with a
404, the German version with a200because a rewrite rule or a translation plugin intercepts the request. - Exits to the wrong language. The error page's links take the German visitor back to the French home page.
A visitor arriving from a broken link, an old search result or a source cited by an AI assistant must be able to carry on in their language. The page's text is a translation matter (see translate error messages and 404 pages (opens in a new tab)); this guide covers the status code, language detection and testing.
What it improves
- Indexing Each language's dead URLs leave the index cleanly, without soft 404s.
- Reports per language Search Console's 404s become readable and actionable by version.
- Crawling Fewer requests wasted on empty pages served with a
200. - Experience Visitors stay in their language and find a path back to the content.
- Rankings No direct effect. Having 404s is not penalizing in itself.
How to check
1. Test one non-existent URL per language. This script requests a random address under each prefix and displays the status code, the number of redirects and the declared language:
for prefix in "" "de/" "en/" "es/"; do
url="https://example.com/${prefix}page-test-404-$RANDOM/"
response=$(curl -s -w '\n%{http_code}' "$url")
status=$(printf '%s' "$response" | tail -n 1)
lang=$(printf '%s' "$response" | grep -o -i -m 1 '<html[^>]*lang="[^"]*"' | grep -o 'lang="[^"]*"')
printf '%s\t%s\t%s\n' "$status" "$lang" "$url"
done
Expected result: 404 on every line and a lang value that matches the prefix (lang="de" for /de/). A 200 indicates a soft 404; a 301 or 302, a redirect to remove.
2. Test each template. An unknown route and an unknown piece of content do not go through the same code. In each language, test at least: a path with no route (/de/xyz/), a non-existent product or article (/de/produkte/xyz/), a non-existent category, and a file (/de/xyz.pdf).
3. Check the page displayed. Open the test URLs: title, message and links must be in the URL's language, and the links must lead to pages in that language.
4. Read the reports. In the Page indexing report, open the “Not found (404)” and “Soft 404” reasons, then filter by language sitemap. A URL-prefix property per language folder (https://example.com/de/) also gives separate reports for each version. In the server logs, count the 404s per language prefix (combined log format):
awk '$9 == 404 {split($7, p, "/"); print p[2]}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
How to implement
Before you start
Target behavior for any non-existent URL:
| Point | Target |
|---|---|
| HTTP status code | 404 (or 410 for content removed on purpose), with no redirect |
| Language | That of the URL's prefix, subdomain or domain |
<html lang> |
That language's code |
| Links | Home page, search and main sections in the same language |
| Hreflang, canonical | None on the error page |
Unknown language (/xx/...) |
404 in the default language |
If the error page is a static file, create one per language (/404.html, /de/404.html, /en/404.html). If it is generated by the application, the language must be inferred from the URL before the error is rendered. The page's useful content is covered in create a helpful 404 page (opens in a new tab).
Apache
Versions Apache 2.4.
In the virtual host, one ErrorDocument directive per language folder:
ErrorDocument 404 /404.html
<Location "/de/">
ErrorDocument 404 /de/404.html
</Location>
<Location "/en/">
ErrorDocument 404 /en/404.html
</Location>
In an .htaccess at the root, where <Location> is not allowed, use <If> blocks (Apache 2.4):
ErrorDocument 404 /404.html
<If "%{REQUEST_URI} =~ m#^/de/#">
ErrorDocument 404 /de/404.html
</If>
<If "%{REQUEST_URI} =~ m#^/en/#">
ErrorDocument 404 /en/404.html
</If>
Always give a local path. With a full URL (https://example.com/de/404.html), Apache sends a redirect and the 404 status code is lost. Test, then reload: sudo apachectl configtest && sudo systemctl reload apache2.
These rules only apply to files served by Apache. For a CMS or framework that routes everything through index.php, the application produces the 404 (see below).
Nginx
Versions Nginx 1.24 and later.
In the server block, one error_page directive per language location:
error_page 404 /404.html;
location /de/ {
error_page 404 /de/404.html;
try_files $uri $uri/ =404;
}
location /en/ {
error_page 404 /en/404.html;
try_files $uri $uri/ =404;
}
location ~ ^/([a-z]{2}/)?404\.html$ {
internal;
}
An error_page declared in a location replaces the one in the server block. Do not write error_page 404 = /de/404.html: the = sign would replace the status code with that of the page served, in other words 200.
For a PHP application, let it produce its own 404: only turn on fastcgi_intercept_errors on if you want to replace its pages with static files. Reload with sudo nginx -t && sudo systemctl reload nginx.
IIS
Versions IIS 10 (Windows Server 2016 to 2025).
In the site's web.config, one section per language folder. responseMode="ExecuteURL" serves the page while keeping the 404 status code:
<configuration>
<location path="de">
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="/de/404.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</location>
</configuration>
existingResponse="Replace" also overrides the 404s produced by the application: use Auto if the application already handles its own error pages.
Cloudflare
Versions Cloudflare dashboard and Cloudflare Pages, all plans, November 2026.
Cloudflare passes the origin's 404 status code through unchanged: the fix is made on the server. Two points to check:
- Redirect rules: an overly broad rule in Rules > Overview can redirect unknown URLs to the home page.
- Cloudflare Pages: Pages serves the nearest
404.htmlfile by walking up the directory tree. Put a404.htmlin each language folder (/de/404.html) in addition to the one at the root. Without a404.htmlat the root, Pages treats the project as a single-page application and serves the home page, which creates soft 404s.
After the fix, purge the cache in Caching > Configuration.
AWS
Versions AWS console (CloudFront, S3, Lambda@Edge), November 2026.
CloudFront custom error responses (the distribution's Error pages tab) map a single page to each error code, for the whole distribution: they cannot choose a page per language. Have the origin produce the localized 404, or use a Lambda@Edge function on the origin response event.
Warning: the configuration often recommended for single-page applications on S3 and CloudFront, which returns
/index.htmlwith a200status code for any403or404error, turns every non-existent URL into a soft 404, in every language. If the site is server-rendered or static, remove this rule.
Netlify
Versions Netlify, all plans, November 2026.
Add one rule per language in the _redirects file at the root of the published site:
/de/* /de/404.html 404
/en/* /en/404.html 404
Netlify only serves these pages for paths that do not match any existing file. The root 404.html is still used for other paths.
Plesk
Versions Plesk Obsidian 18.0 for Linux.
On Plesk for Linux, use the .htaccess block from the Apache section if Apache serves the files, or paste the block from the Nginx section (without the try_files directives if an application handles the URLs) into Websites & Domains > your domain > Apache & nginx Settings (“Hosting & DNS” tab in the Dynamic List view), “Additional nginx directives” field.
cPanel
Versions cPanel & WHM 110 and later, Jupiter theme.
cPanel's Advanced > Error Pages tool edits a single page per code for the whole domain (404.shtml). For one page per language, add the .htaccess block from the Apache section to public_html/.htaccess with the File Manager.
Shared hosting
With most shared hosting providers, Apache or LiteSpeed reads the .htaccess: the <If> block from the Apache section works as is. Then check with the script from the “How to check” section that the status code is still 404.
WordPress
Versions WordPress 6.4 to 7.1; WPML 4, Polylang 3.
WordPress displays the theme's 404.php template with the 404 status code. With WPML or Polylang and languages in subfolders, the language is inferred from the URL prefix: the error page comes out in the URL's language if its texts are translated (the theme's translation files, or WPML or Polylang string translation). Points to check:
- Plugins that redirect 404s to the home page: deactivate them, they create soft 404s in every language.
- Links on the error page: use
home_url('/'), which returns the current language's home page with WPML and Polylang, rather than a hard-coded URL. - Page builders: if the 404 is a page designed with a builder, check that it exists in each language.
Shopify
Versions Shopify admin and the Translate & Adapt app, all plans, November 2026.
Shopify returns a 404 status code for a non-existent resource and displays the theme's 404 template. This template's texts come from the theme's language files: translate them in the Translate & Adapt app, in the section dedicated to theme content. Test a non-existent URL under each published language prefix (/de/products/xyz) to check the language displayed.
Laravel
Versions Laravel 10 to 13.
A route that cannot be found throws the exception before your routes' language middleware runs: the resources/views/errors/404.blade.php view then comes out in the default language. Set the language from the URL when the error is rendered.
Declare supported_locales (for example ['fr', 'de', 'en']) in config/app.php. In the view, use __() for the texts and app()->getLocale() for the lang attribute and the links. Only the place where the error rendering is hooked in changes from one version to another.
Laravel 11 to 13
Since Laravel 11, app/Exceptions/Handler.php no longer exists in new applications: exception rendering is configured in bootstrap/app.php.
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->render(function (NotFoundHttpException $e, Request $request) {
$locale = $request->segment(1);
if (in_array($locale, config('app.supported_locales'), true)) {
app()->setLocale($locale);
}
return response()->view('errors.404', [], 404);
});
})
An application upgraded from Laravel 10 that kept its Handler.php follows the next tab.
Laravel 10 and earlier
In the register() method of app/Exceptions/Handler.php:
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
public function register(): void
{
$this->renderable(function (NotFoundHttpException $e, Request $request) {
$locale = $request->segment(1);
if (in_array($locale, config('app.supported_locales'), true)) {
app()->setLocale($locale);
}
return response()->view('errors.404', [], 404);
});
}
Next.js
Versions Next.js 15 and 16 (App Router).
In the App Router, a URL that matches no route displays app/not-found.tsx, outside the language layout. For a language's unknown URLs to display that language's 404, add a catch-all route that calls notFound() inside the [lang] segment:
// app/[lang]/[...rest]/page.tsx
import { notFound } from 'next/navigation'
export default function CatchAll() {
notFound()
}
The not-found.tsx file does not receive the route parameters. Read the language from the path with a client component:
// app/[lang]/not-found.tsx
'use client'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
const messages = {
fr: { title: 'Page introuvable', home: "Retour à l'accueil" },
de: { title: 'Seite nicht gefunden', home: 'Zur Startseite' },
en: { title: 'Page not found', home: 'Back to home' },
} as const
type Lang = keyof typeof messages
export default function NotFound() {
const segment = usePathname().split('/')[1]
const lang: Lang = segment in messages ? (segment as Lang) : 'fr'
return (
<main>
<h1>{messages[lang].title}</h1>
<Link href={`/${lang}`}>{messages[lang].home}</Link>
</main>
)
}
The app/[lang]/layout.tsx layout sets the page's lang attribute. If this layout is your root layout (no app/layout.tsx), Next.js 15.4 and later offer, for URLs outside any language segment, the app/global-not-found.tsx file, still experimental (experimental.globalNotFound option in next.config.ts). Next.js adds <meta name="robots" content="noindex"> to not-found pages, but the status code stays 200 if streaming has already started: check the status code with curl and call notFound() before any slow data fetching.
Common mistakes
- Testing only the default language: the defects almost always show up in the other languages.
- Redirecting 404s to the home page: Google often treats these redirects as soft 404s, and the visitor loses their language.
- Giving
ErrorDocumenta full URL orerror_pagean=: the404status code becomes a redirect or a200. - Putting an hreflang or a canonical on the error page: it has no equivalent to announce.
- Forgetting files: a missing PDF or image under
/de/goes through different rules from pages. - A single error page shared by a CDN or a single-page application: it masks the 404s of every language.
Frequently asked questions
Do you need a different 404 page for each language?
Yes, each language on a multilingual site should display its own 404 page, in the language of the requested URL, with links to that language's home page and sections. The HTTP status code must remain 404 in every case. A single error page in the default language is not a technical fault, but it leaves foreign visitors stranded when they arrive from a broken link or an old result.
Why is my 404 page displayed in the wrong language?
The 404 page is often displayed in the default language because the application sets the language after finding the route. When the URL matches no route, that setting never happens. The fix is to read the language from the URL's prefix, subdomain or domain when the error is rendered, in the application's exception handler or in the server configuration.
Do 404 errors hurt a language's SEO?
No, 404 errors on URLs that do not exist do not penalize the rankings of other pages, in any language. Google simply removes those URLs from the index. The problem lies with 404s on pages that should exist, broken internal links and soft 404s, in other words not-found pages served with a 200 status code or redirected to the home page.
How do you see the 404 errors of a single language in Search Console?
To isolate a language's 404 errors in Search Console, open the Page indexing report and filter by that language's sitemap, if each language has its own sitemap. You can also add a URL-prefix property for the language's folder, for example https://example.com/de/: all its reports, including the “Not found (404)” reason, then only concern that version.
Resources
- Google Search Central: HTTP status codes and network errorsdevelopers.google.com
- Search Console Help: Page indexing reportsupport.google.com
- Apache: ErrorDocument directivehttpd.apache.org
- Nginx: error_page directivenginx.org
- Cloudflare Pages: 404 pagesdevelopers.cloudflare.com
- Netlify: Custom 404 pagesdocs.netlify.com
- Laravel: Error handlinglaravel.com
- Next.js: not-found.jsnextjs.org
Updated on
Topic checklist (PDF)