Skip to content

Conversation

@caugner
Copy link
Contributor

@caugner caugner commented Nov 6, 2025

Description

Refines the redirect logic when an MDN url without locale is accessed, preferably choosing a locale where the target page actually exists.

Motivation

Avoids redirects to 404s, when the page does not exist in the user's primary preferred locale, but in another accepted locale, or in English (as a fallback).

Additional details

Deployed to the test environment, and verified:

Before

$ xh -h GET https://developer.allizom.org/docs/Web/API/WebCodecs_API "Accept-Language: fr, en"
HTTP/2.0 302 Found
(…)
location: /fr/docs/Web/API/WebCodecs_API
(…)
$ xh -h GET https://developer.allizom.org/docs/Web/API/WebCodecs_API "Accept-Language: es, fr"
HTTP/2.0 302 Found
(…)
location: /es/docs/Web/API/WebCodecs_API
(…)

After

$ xh -h GET https://test.developer.allizom.org/docs/Web/API/WebCodecs_API "Accept-Language: fr, en"
HTTP/2.0 302 Found
(…)
location: /en-US/docs/Web/API/WebCodecs_API
(…)
$ xh -h GET https://test.developer.allizom.org/docs/Web/API/WebCodecs_API "Accept-Language: es, fr"
HTTP/2.0 302 Found
(…)
location: /en-US/docs/Web/API/WebCodecs_API
(…)

Related issues and pull requests

Fixes #79.

@caugner caugner force-pushed the 79-prefer-locale-where-page-exists branch from f46de51 to 7906455 Compare November 6, 2025 13:01
@caugner caugner marked this pull request as ready for review November 6, 2025 15:06
@caugner caugner requested a review from a team as a code owner November 6, 2025 15:06
@caugner caugner requested a review from argl November 6, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URLs without locales do not do correct locale fallback

1 participant