From d52ab0b1e99aa0c494f389092dce1e926296032d Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 12 Sep 2020 12:42:19 +0200 Subject: Properly handle 404 errors Use 404 template instead of default Slim error page if the route is not found. Fixes #827 --- .../controller/visitor/ErrorNotFoundController.php | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 application/front/controller/visitor/ErrorNotFoundController.php (limited to 'application/front') diff --git a/application/front/controller/visitor/ErrorNotFoundController.php b/application/front/controller/visitor/ErrorNotFoundController.php new file mode 100644 index 00000000..758dd83b --- /dev/null +++ b/application/front/controller/visitor/ErrorNotFoundController.php @@ -0,0 +1,29 @@ +getRequestTarget(), '/api/v1')) { + return $response->withStatus(404); + } + + // This is required because the middleware is ignored if the route is not found. + $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/'); + + $this->assignView('error_message', t('Requested page could not be found.')); + + return $response->withStatus(404)->write($this->render('404')); + } +} -- cgit v1.2.3