From 82e69c7259d7a829f2a2af357a5741956b5bf2ab Mon Sep 17 00:00:00 2001 From: isUnknown Date: Mon, 1 Jun 2026 10:01:49 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20redirects=20301=20not=20firing=20?= =?UTF-8?q?=E2=80=94=20three=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - toPages()->first() instead of toPage() (pages field stores YAML array) - Force read from default language content to avoid empty rules on FR requests - Add error.php template so Kirby uses the error controller (without it, Kirby fell back to default template and ignored site/controllers/error.php) Co-Authored-By: Claude Sonnet 4.6 --- site/controllers/error.php | 6 ++++-- site/templates/error.php | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 site/templates/error.php diff --git a/site/controllers/error.php b/site/controllers/error.php index 2a246f5..d1afaa1 100644 --- a/site/controllers/error.php +++ b/site/controllers/error.php @@ -13,11 +13,13 @@ return function ($kirby, $page, $site) { $map = []; $redirectsPage = $site->find('redirections'); if ($redirectsPage) { - foreach ($redirectsPage->rules()->toStructure() as $rule) { + $defaultLang = $kirby->defaultLanguage()?->code() ?? 'fr'; + $rules = $redirectsPage->content($defaultLang)->rules()->toStructure(); + foreach ($rules as $rule) { $from = trim($rule->from()->value()); if ($from === '') continue; $key = '/' . trim(strtolower($from), '/'); - $target = $rule->to()->toPage(); + $target = $rule->to()->toPages()->first(); if ($target) { $map[$key] = $target->url(); } diff --git a/site/templates/error.php b/site/templates/error.php new file mode 100644 index 0000000..b794960 --- /dev/null +++ b/site/templates/error.php @@ -0,0 +1,3 @@ + +
+