On my multilanguage website, when someone is visiting a page which isn’t published or doesn’t exist, I would like to redirect to the error page with the right translation using a route (so URL becomes /404 or /en/404). I’ve tried the following code but it doesn’t work…
I’m wondering what you are trying to achieve here? On a multi-language site, don’t you automatically get the correct error page when a page doesn’t exist? at least that should be the case…
But yes, you can of course check if a user is logged in
if (!$page || (!kirby->user() && $page->isPublished()) {
// do stuff
}
I’m using the Swup JS library to play with the history API and I need error pages to redirect to a specific URL in order to animate correctly transitions, so this is very specific. I’ll try to find an alternative and will share here the solution.