I have a router setup to remove the /home/ from my primary blog post URLs.
It works great, but when viewing drafts, I’m always redirected to my error page. The draft URL with the temporary token includes /home/ in the URL, and I’m assuming that’s part of the problem, but I can’t seem to find my way around the issue.
This is my config.php file:
return [
'debug' => false,
'routes' => [
[
'pattern' => '(:any)',
'action' => function ($uid) {
$page = page($uid);
if (!$page) $page = page('home/' . $uid);
if (!$page) $page = site()->errorPage();
return site()->visit($page);
}
],
[
'pattern' => 'home/(:any)',
'action' => function ($uid) {
go($uid);
}
]
],
];