Handling multiple 404's?


#1

Consider having two routes one is the frontpage the other for the backend.
Currently when triggering a 404 on the frontpage it shows the not found page.
When doing the same on the backend route it redirects to the front page to display the not found page.

Is there a way to display a not found page while staying in the backend url/route?


Best strategy for different 404s in different website sections
404 notFoundHandler - different template for routes
#2

You can register to the notFoundHandler and handle specific pages differenty

Example code:

   $c = new Container();
    $c["notFoundHandler"] = function (Container $c) {
        return function (Request $req, Response $resp) use ($c) {
            //get url with $request->getUri()->getPath()
            return $resp->withStatus(404);
        };
    };
   $app = new App($c);

#3

Thanks for the reply, i’ll test it out.