[eluser]Dean Rantala[/eluser]
**SOLVED**
This one needs to be a sticky.
Also suprised this is not a core feature.. but here we go:
1) Open system/libraries/Router.php
2) Around line 238 you will find "Can't find the requested controller"
This is our magic moment! Why.. oh why.. could the core devs not thing about letting you define a default "404 conntroller"?
3) Alter this:
// Can't find the requested controller...
show_404($segments[0]);
To look like this:
// Can't find the requested controller...
if( file_exists(APPPATH.'controllers/controllernotfound.php'))
{
$this->set_class('controllernotfound');
$this->set_method('index');
}
else
{
show_404($segments[0]);
}
Presto! Of coarse, you could get fancy and do a check to see if a default "404 controller" is defined in your config somewhere - but this gets the job done.
Now create a controllers/controllernotfound.php class and for the index method, do a "print 'it works'" or something to test.
You now have a central spot to test for a CMS page, perhaps run a Lucene search (for "page not found - but here are some similar search results"), or even just a really fancy 404 page.
Hope this helps
- Dean