Check 23.09 · Hreflang and regional variants

Check that targets return HTTP 200

Check that every URL cited in your hreflang returns 200, find the cause of 3xx, 4xx and 5xx on the server, CDN or CMS, and fix the source of the annotations.

Priority
Critical
Difficulty
Intermediate
Estimated time
1 to 4 h
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

Every URL cited in an hreflang annotation must return 200 OK directly: no redirect, no 404 error, no 403 block, no server error. The task consists of extracting all the target URLs from the annotations (HTML, sitemap, headers), testing their response code as crawlers receive it, then fixing either the announced URL or the server's response. Once it is done, a full crawl no longer reports any hreflang target outside 200.

Why it matters

Google requires annotations to be reciprocal: if page A announces page B, page B must announce page A in return, otherwise the annotations may be ignored. This check assumes that Google can crawl B and read the return link there. A target returning 404, 410, 403 or 5xx sends nothing back: the pair is lost, and the version concerned will not be offered to the right audience.

Redirects are less serious but costly. Asked in 2025 about annotations pointing to URLs redirected with a 301 after a migration, Google's John Mueller replied that it was "probably fine", while advising to automate the annotations so that they point directly to the final URLs. A redirected target forces the crawler to follow one more hop, and the consistency of the group then depends on its ability to connect the old URL and the new one.

The typical causes are mundane: annotations written in http:// when the site forces HTTPS, a missing trailing slash, an old translated slug, a deleted translation, a staging version protected by a password, a firewall that blocks crawlers on a single subdomain.

What it improves

  • Annotations taken into account Each pair of versions can be verified and kept by Google.
  • Crawling Fewer requests wasted on redirects and errors. Noticeable on large multilingual catalogs.
  • Experience A visitor following a language switcher fed by the same data no longer lands on a 404.
  • Generative engines Indirect effect. Versions that respond correctly can be crawled by AI crawlers; nothing guarantees they will be cited.
  • Rankings No direct effect.

How to check

1. On one page, without a paid tool. This script extracts the URLs from a page's hreflang annotations and tests each one without following redirects:

#!/usr/bin/env bash
# Usage: bash hreflang-codes.sh https://example.com/fr/tarifs/
page="$1"

curl -s "$page" \
  | grep -o -i '<link[^>]*hreflang[^>]*>' \
  | grep -o -i 'href="[^"]*"' \
  | cut -d'"' -f2 \
  | sort -u \
  | while read -r url; do
      result=$(curl -s -o /dev/null -w "%{http_code} %{redirect_url}" "$url")
      code=${result%% *}

      if [ "$code" = "200" ]; then
        echo "OK      $code  $url"
      else
        echo "ALERT   $result  <- $url"
      fi
    done

Correct result: only OK 200 lines. An ALERT 301 https://… line shows the URL the target redirects to. The script assumes attributes in double quotes, which is the case for most CMSs.

2. In a sitemap. Same principle on the xhtml:link elements:

curl -s https://example.com/sitemap.xml \
  | grep -o -i '<xhtml:link[^>]*>' \
  | grep -o -i 'href="[^"]*"' \
  | cut -d'"' -f2 \
  | sort -u \
  | while read -r url; do
      echo "$(curl -s -o /dev/null -w '%{http_code}' "$url") $url"
    done \
  | grep -v "^200 "

No lines shown: compliant.

3. Across the whole site. In Screaming Frog, enable storing and crawling hreflang annotations in Configuration > Spider > Crawl, then start the crawl. In the Hreflang tab, the "Non-200 Hreflang URLs" filter lists targets that are blocked, unresponsive, redirected or in error; the export is under Reports > Hreflang. Site audits in Ahrefs, Semrush or Sitebulb report the same issue.

4. From Google's point of view. Test a suspicious target with Search Console's URL Inspection tool, live test: it shows the code Googlebot receives, which reveals firewall blocks that a curl from your machine does not see. The Page indexing report also classifies known URLs as "Page with redirect", "Not found (404)" or "Server error (5xx)".

How to implement

Before you start

For each target outside 200, choose the right fix:

Target's response Usual cause Fix
301 or 308 to the same page (HTTPS, www, slash) URL announced in a non-final form Fix how the annotations are generated
301 to a new translated URL Slug changed, migration Announce the new URL; keep the redirect for visitors
302 or 307 depending on country or language Geographic redirect Remove the redirect (see avoid forced redirects based on browser language (opens in a new tab))
404 or 410 Translation missing or deleted Remove the version from the group (see exclude redirects and nonexistent pages (opens in a new tab))
401 or 403 Staging, firewall, geoblocking Open the page to crawlers or remove it from the group
5xx Application error in one language Fix the application (see fix 5xx errors (opens in a new tab))

Remember the rule: fix the annotation so that it designates the URL that returns 200; do not create a redirect to make up for a wrong annotation.

Also set the canonical form of URLs once and for all: protocol, subdomain, trailing slash, case. Every annotation must use it (see use absolute URLs (opens in a new tab)).

Apache

Versions Apache 2.4.

Find the rules that produce the normalization redirects, to know the exact final form:

sudo grep -rn -i -E "RewriteRule|Redirect(Match|Permanent)?" /etc/apache2/sites-enabled/ /var/www/*/.htaccess 2>/dev/null

A common example in .htaccess: HTTPS and www forced.

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

With this rule, any annotation in http:// or without www produces a 301: fix the base URL used by the application or CMS, not the rule. If mod_security or fail2ban return 403s on one language, check /var/log/apache2/error.log at the time of the request.

Nginx

Versions Nginx 1.18 and later.

Same search:

sudo grep -rn -E "return 30[1278]|rewrite .* (permanent|redirect)" /etc/nginx/

Normalization redirects usually sit in a separate server block (return 301 https://www.example.com$request_uri;). For 403s, look for deny rules and rate limits (limit_req) that return an error to crawlers on one version:

sudo grep -rn -E "deny|limit_req|auth_basic" /etc/nginx/sites-enabled/

A version protected by auth_basic (staging put online too early) must be removed from the annotations as long as it is not public.

Cloudflare

Versions Cloudflare dashboard, all plans, November 2026.

Three sources of non-200 responses to check:

  • Redirect rules: in the Rules overview, review the Redirect Rules and legacy Page Rules that affect the language folders.
  • HTTPS settings: SSL/TLS > Edge Certificates, "Always Use HTTPS" option: it redirects any annotation in http://.
  • Security: in the domain's security events, filter on the target paths. A challenge or block on one version (country rule, custom WAF rule) shows up as a 403 response for crawlers. See check CDN, WAF and anti-bot protection (opens in a new tab).

After the fix, purge the cache for the affected URLs.

AWS

Versions AWS console (CloudFront, AWS WAF, S3), November 2026.

On CloudFront, language or country redirects often come from a CloudFront Function or a Lambda@Edge function associated with the "Viewer request" event; 403s may come from AWS WAF or from the distribution's geographic restriction. On S3 static hosting, a missing translated page returns 404 or 403 depending on the bucket's list permissions: check that the file exists at the exact key announced, trailing slash included (fr/tarifs/index.html).

WordPress

Versions WordPress 6.4 to 7.1; WPML 4 and 5, Polylang 3, November 2026.

Multilingual plugins build URLs from permalinks: discrepancies often come from the settings.

  • Site address: in Settings > General, "WordPress Address (URL)" and "Site Address (URL)" must be in https:// and in the final form (with or without www).
  • Trailing slash: the structure in Settings > Permalinks sets the form; an annotation without the trailing slash produces a 301.
  • Per-language domains (WPML, Polylang): each declared domain must have its certificate and respond directly, otherwise every annotation to that language fails.
  • Redirect plugin (Redirection, Rank Math, Yoast SEO Premium): a rule that is too broad can capture a language folder.

After the fix, clear the page cache and run the test again.

Shopify

Versions Shopify admin, all plans, November 2026.

Automatic annotations follow the markets' domains and subfolders. Targets outside 200 come from a badly connected market domain (Settings > Domains), a deactivated market still referenced by a theme that writes its own tags, or a modified translated handle. When you change a handle, leave the URL redirect option ticked for visitors, but check that the annotations do announce the new handle.

Laravel

Versions Laravel 11 to 13.

Always generate target URLs with the route() helper, never by concatenation, and set the root URL for requests served behind a proxy:

// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\URL;

public function boot(): void
{
    if ($this->app->isProduction()) {
        URL::forceScheme('https');
        URL::forceRootUrl(config('app.url'));
    }
}

Add a test that goes through a page's annotations and checks that each target returns 200:

public function test_hreflang_targets_return_200(): void
{
    $html = $this->get('/fr/tarifs')->assertOk()->getContent();

    preg_match_all('/<link[^>]+hreflang="[^"]+"[^>]+href="([^"]+)"/i', $html, $matches);

    foreach (array_unique($matches[1]) as $url) {
        $this->get(parse_url($url, PHP_URL_PATH))->assertOk();
    }
}

Next.js

Versions Next.js 15 and 16 (App Router).

The trailingSlash option in next.config.js (or next.config.ts) decides the final form: with trailingSlash: true, /fr/tarifs redirects to /fr/tarifs/. The URLs in alternates.languages must follow the same form. Also check that no language redirect lives in proxy.ts (named middleware.ts before Next.js 16) and that generateMetadata only announces the locales for which the page exists: a route that calls notFound() in one language must not appear in the annotations of the others.

Common mistakes

  • Testing with curl -L: the option follows redirects and shows 200 at the end of the chain, which hides the problem.
  • Fixing with a redirect instead of fixing the annotation: you add a hop instead of removing one.
  • Testing only from your own machine: a firewall or geographic rule may return 403 to crawlers and 200 to you. Use Search Console's live test.
  • Forgetting the sitemap when the annotations are also declared there.
  • Leaving annotations pointing to staging or a test domain, often password-protected.
  • Treating a soft 404 as a success: a "translation unavailable" page that returns 200 passes the test but is still useless. See fix soft 404s (opens in a new tab).

Frequently asked questions

Can an hreflang annotation point to a redirected URL?

It is not recommended. In 2025, Google's John Mueller considered that annotations pointing to 301 redirects after a migration were probably acceptable, while advising to automate the annotations so that they point directly to the final URLs. Each redirect adds a hop to crawling and weakens the verification of return links. Fix the source of the annotations so that it announces the URL that returns 200.

What happens if an hreflang target returns a 404 error?

A target returning 404 cannot send back a return link: Google cannot confirm the pair, and the annotations between that page and the other versions may be ignored. The missing version is not offered to the intended audience. Remove the URL from the group in the CMS or the annotation generator, and only put it back once the translation is published and accessible.

How do you test the HTTP code of every hreflang URL on a site?

A crawler such as Screaming Frog, with hreflang crawling enabled, lists every target that does not return 200 in a dedicated filter. Without a paid tool, a curl script can extract the URLs from a page's link tags or a sitemap's xhtml:link elements and test each one without following redirects. Complete this with Search Console's live test to see the response Googlebot receives.

Why does a page return 200 in my browser and 403 for Googlebot?

A web application firewall, a country rule, a rate limit or anti-bot protection can block crawlers without affecting visitors. Googlebot crawls mostly from addresses located in the United States: a rule that filters that country on one language version makes it invisible. The live test in Search Console's URL Inspection tool shows the response Google actually receives.

Updated on

Topic checklist (PDF)

And now?

In the “Hreflang and regional variants” topic

  1. Implement hreflang for equivalent pages
  2. Check reciprocity
  3. Include the self-referencing annotation
  4. Use absolute URLs
  5. Validate ISO 639-1 language codes
  6. Validate ISO 3166-1 Alpha-2 country codes
  7. Use en-GB rather than en-UK
  8. Use x-default if relevant
  9. Check that targets return HTTP 200
  10. Check that targets are indexable
  11. Exclude redirects and nonexistent pages
  12. Align hreflang and canonical
  13. Automate annotations through the CMS
  14. Update annotations when a translation is removed
  15. Use HTTP headers for PDFs if needed
  16. Check consistency across HTML, HTTP header and sitemap methods if combined
  17. Test same-language variants for different countries