Skip to content

Commit 7f9f5e8

Browse files
authored
Update 404.html
1 parent 9b85234 commit 7f9f5e8

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

overrides/404.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
<head>
44
<title>Redirection...</title>
55
<script>
6-
const pathname = window.location.pathname;
6+
const pathname = window.location.pathname;
77

8-
// Vérifie si l'URL commence par "/doc/" suivi d'une langue (ex: /doc/fr/, /doc/en/, etc.)
9-
const docMatch = pathname.match(/^\/doc\/([a-z]{2})\/(.+)/);
8+
// Vérifie si l'URL commence par "/doc/" suivi d'une langue (ex: /doc/fr, /doc/fr/SLUG, /doc/en, etc.)
9+
const docMatch = pathname.match(/^\/doc\/([a-z]{2})(\/.*)?$/);
1010

1111
if (docMatch) {
12-
// docMatch[1] = langue (ex: "fr", "en")
13-
// docMatch[2] = slug (tout ce qui suit la langue)
1412
const lang = docMatch[1];
15-
const slug = docMatch[2];
16-
window.location.href = `/${lang}/${slug}`;
13+
const slug = docMatch[2] || ''; // Si pas de slug, slug = chaîne vide
14+
window.location.href = `/${lang}${slug}`;
1715
} else {
1816
// Si ce n'est pas une URL à rediriger, affiche une vraie page 404
1917
document.write("Page non trouvée.");

0 commit comments

Comments
 (0)