Is there a way or a function within a controller that tells if a 404 error was triggered? I would like everyone to redirect at the homepage instead of seeing a 404 page.
Thanks!
Is there a way or a function within a controller that tells if a 404 error was triggered? I would like everyone to redirect at the homepage instead of seeing a 404 page.
Thanks!
To catch and handle 404 errors, you need to extend the ErrorHandler
class and override the error404
method. To do that, create the file app/app_error.php
with the following code:
class AppError extends ErrorHandler {
function error404($params) {
// redirect to homepage
$this->controller->redirect('/');
}
}