Locale redirect trap audit
Session or cookie-based language redirects routinely make one language unreachable. If the default locale has no URL prefix, an unprefixed path carries no locale signal, so the redirect middleware treats it as unset and sends the visitor to whatever was stored - meaning the default language can never be selected again. The same mechanism serves the wrong language to anyone opening a shared link, and can undermine hreflang entirely.
Use when visitors report being unable to switch back to a language, or when a shared link opens in the wrong language for the recipient.
The skill file
What you need first
- The site with locale switching enabled
- curl or any client that can hold and replay cookies
Method
- 01 Request a prefixed URL in a non-default language to establish a stored preference.
- 02 Replay the same client, now requesting the unprefixed equivalent. If it 302s back to the stored language, the default locale is unreachable and the bug is confirmed.
- 03 Repeat for a deep path, not just the home page. A redirect that only fires at the root is acceptable; one that fires on every path is not.
- 04 Request the default-language URL with no cookie at all - this is what a crawler sees. If it redirects, hreflang validation will fail regardless of how correct the markup is.
- 05 Fix by making the URL authoritative: only ever act on a stored preference at the bare root, and only record a preference when the visitor explicitly asks for one via the switcher.
- 06 Re-test all four cases: choose a language, return to root, choose the default language, and open an explicit path with a conflicting preference stored.
What this produces
A four-case pass/fail matrix proving every language is reachable, explicit URLs are never overridden, and a cookieless request receives the canonical default.
Where this goes wrong
- Testing only the home page, where the bug is least visible
- Testing with a browser that already holds a preference, so the broken path never triggers
- Assuming crawlers are unaffected - they are not, because the redirect changes what is served at the canonical URL
Use this skill in your own AI
The download is a plain markdown file with the name and trigger in its frontmatter. Where an assistant supports skills it can load itself, that frontmatter is what it reads to decide this one applies.
Questions about this skill
When is a cookie replay test better than reading the middleware?
Reach for it when someone cannot switch back to a language, or a shared link opens in the wrong one. Reading the middleware tells you what it intends; replaying a client that holds a stored preference tells you what it does. Clicking around in your own browser will not find it, because your browser already holds a preference.
What do I need in hand before starting?
The site with locale switching live, and a client that can hold and replay cookies, such as curl with a cookie jar. Start without cookie control and you test only the state you happen to be in, which is the one case that already works, and you come away convinced the reported bug is not real.
What do I end up with, and which part of it gets used?
A four-case pass or fail matrix: choose a language, return to root, choose the default language, then request an explicit path with a conflicting preference stored. The cookieless request for the default-language URL is the case that matters most, because that is what a crawler receives, and a redirect there invalidates hreflang however correct the markup is.
What ruins this most often?
Testing only the home page. A redirect firing at the bare root is defensible and is where people look; the damage sits on deep paths, where an explicit URL gets overridden and the default locale becomes unselectable. The cost is a language nobody can reach, shared links opening wrong, and hreflang failing for reasons that never appear in the markup.
More in International SEO
Hreflang reciprocity repair
Use when translated pages exist and are indexed but never surface for the right country, or when...
Translation key drift guard
Use on any site whose translation keys are the English source text, where editing a headline sil...
RTL layout audit
Use before shipping Arabic, Hebrew, Farsi or Urdu, or when an RTL locale shows overlapping text,...
Multilingual sitemap coverage
Use when translated pages exist and are linked but receive no impressions, and the sitemap lists...