• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
404 Error


I want to use my own controller as 404 error. I setup the routes correctly and it works great!
But there is one thing.. When I use the 404_error() function, I don't get my own controller...

Does someone have a solution for this?


A quick, easy work-around is to use a MY_Controller base controller, and define a method for generating the 404. I'd name it something like _throw_404() to avoid any name collisions, and make it protected. Take your current custom 404 controller's code and transfer it to this method.

Then, have your original error controller A) extend MY_Controller, and B) call the new $this->_throw_404() method.

Also, any other controllers where you wish to throw a 404 error using show_404(), you'd do those steps instead - extend MY_Controller and call $this->_throw_404();

Thanks for your reply! Smile

I was already using a MY_Controller, stupid that (.. How do you say that in English).
But thanks for this solution Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.