CodeIgniter Forums
Show a Controller Instead of the 404 File - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Show a Controller Instead of the 404 File (/thread-12196.html)



Show a Controller Instead of the 404 File - El Forum - 10-09-2008

[eluser]Unknown[/eluser]
Is there a way to get codeignitor to show a controller instead of the 404 html file?
I need it this way because the headers on the site changes depending on if the user is logged in or not.

Thanks in advance.


Show a Controller Instead of the 404 File - El Forum - 10-09-2008

[eluser]Mirage[/eluser]
The 404 html file is a php file. show_404() outputs that file. So all you need to do is write some php code in the error_404.php that gets checks the login status and then itself executes further output.

You do want to be careful in what you put in there of course, because if you subsequently call stuff that causes the framework to trigger a show_404(), you'll enter a race condition.

Cheers,
-m