Codeigniter 4 - how to show 404 page?
I was looking just now exactly for the same thing.I found here the solution: CodeIgniter 4 User Guide - Error Handling
In your controller, simply write:
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
U can try this
<?php // Would execute the show404 method of the App\Errors class $routes->set404Override('App\Errors::show404'); // Will display a custom view $routes->set404Override(function() { echo view('my_errors/not_found.html'); });
https://codeigniter4.github.io/userguide/incoming/routing.html#override