Hi, i have problems with my routing code, Could someone please give some advice on how to fix this?
-
When we want to add a file which should be used as a link for some elements of the website. When we upload the document (for example a pdf) in the files tab, the files link is not actually correct and returns a 404 page /panel/site/files/test.pdf. Opened like that test.de Archiv | Stiftung Warentest. Basically, by adding /content/ slug after domain and before the file name, we can use the file as a link but it is not so easy to be applied. links like that works good /panel/pages/home+pressemitteilung-fort-knox/files/test.pdf. Opened like that /media/pages/home/pressemitteilung-fort-knox/5da8b76798-1710163624/test.pdf
-
There’s another issue with the 302 redirects. Basically when we go to a link like home/test its replased like test, it dont shows the slug /home/ but it’s actually homepage and should be only the domain. Also, the links for articles are actually domain/home/article-name but they are redirected to domain/article-name. It’s not the best practice specifically for SEO.
Here the code:
'routes' => [
[
'pattern' => '(:any)',
'action' => function($uid) {
$page = kirby()->page($uid);
if(!$page) $page = kirby()->page('home/' . $uid);
if ($page && $page->status() === 'draft' && ! kirby()->user()) {
return site()->visit(page('error'));
}
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
],
[
'pattern' => 'home/(:any)',
'action' => function($uid) {
go($uid);
}
]
]