swordfish
swordfish

Reputation: 4995

codeigniter custom 404 page not working

In codeigniter routes file there is a setting called

$route['404_override'] = 'general/not_found';

So as you can see i have given a method there. The problem is this isnt working properly. From some pages the error 404 is showing the page that ive set in the method but for some pages it is showing the default codeigniter 404 page.

So i assume that this is a bug in the framework itself. Have anyone of you faced this before? If so what is the best bypass method available to get all 404 pages return custom page?

Upvotes: 3

Views: 3784

Answers (2)

Damien Pirsy
Damien Pirsy

Reputation: 25435

I answered to something similar on this SO question

Basically, that's not a bug because custom re-routed error messages don't affect the calling of the core function show_404(), but only the controller-generated error message.

In order to solve this you need to make a small hack to the core show_404() inside the Exception class, and its consequent call on the show_error() function in common.php. Alternatively, follow @Eric LaForce suggestion and modify/extend the Exception class in order to work on your new directives.

Upvotes: 3

Eric LaForce
Eric LaForce

Reputation: 2151

Without more detail on which pages show the 404 and which do not, I am not sure, but it sounds like this person has also run into a similar situation and has devised a solution. At the very least it may point you in the correct direction. Hope it helps.

Upvotes: 0

Related Questions