Hello all!
I tweaked this code from the Kirby site, to redirect pages in the rhymes/ folder.
'routes' => [
[
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if(!$page) $page = page('rhymes/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
],
[
'pattern' => 'rhymes/(:any)',
'action' => function($uid) {
go($uid);
}
],
[
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if ($page instanceof Page === false) go('https://google.com');
}
],
]
Which works fine, but now Kirby does not redirect anymore on an error.
I add the last bit, bu t it does not work yet.
It is not even loading the template as the error occurs before that.
In the template:
<?php
if($page->title() == 'error' ) {
go($site->homePage(), 301);
}
?>
Any ideas? Thanks!!