Hi there! I’m dealing with a path like portfolio/categories/category-1
and I want to remove the slug in the middle of the path (categories
). According to the basic blog example my initial try looks like that:
<?php
return [
'routes' => [
[
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if(!$page) $page = page('portfolio/categories/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
],
[
'pattern' => 'portfolio/categories/(:any)',
'action' => function($uid) {
go('portfolio/' . $uid);
}
]
]
];
It redirects to /portfolio/category-1
as it should but it’s ending up on the error page. Any idea what I’m doing wrong here?