fix: redirects 301 not firing — three bugs
All checks were successful
Deploy Production / Deploy to Production (push) Successful in 26s
All checks were successful
Deploy Production / Deploy to Production (push) Successful in 26s
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
dbeca5e095
commit
82e69c7259
2 changed files with 7 additions and 2 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
3
site/templates/error.php
Normal file
3
site/templates/error.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?php snippet('header') ?>
|
||||
<div id="ssr-content"></div>
|
||||
<?php snippet('footer') ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue