CodeIgniter Forums
Customize 404 error page but not only the view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Customize 404 error page but not only the view (/showthread.php?tid=82543)



Customize 404 error page but not only the view - serialkiller - 07-21-2022

I'm trying to customize the 404 error page but the only way I've found is to edit the Routes.php file in the Config folder like so:

PHP Code:
$routes->set404Override(function () {
    return view('pages/my404');
}); 
In this way, however, I have no control because I do not have a Controller and Model (if necessary), but only a view.

Is there a way to switch from the Controller and not directly from the view?


RE: Customize 404 error page but not only the view - kenjis - 07-21-2022

You can set a controller and method.
See https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html#override


RE: Customize 404 error page but not only the view - serialkiller - 07-21-2022

(07-21-2022, 01:07 AM)kenjis Wrote: You can set a controller and method.
See https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html#override

Perfect thanks