Redirect is cleanest; loading a view could work too.
The problem here is that show_404() is usually called AFTER your controller has already loaded (something had to tell it show the 404 after all). CI doesn't like loading a second controller at that point, which is the primary hurdle.
Your best option probably is extending the show_404() function in the Exceptions class to redirect to your 404 route. Without a redirect, you'll be stuck with showing a view or something that you know has all the "extra data" it needs prior to calling the 404 (or I guess you could load it in the Exceptions class too). It can get really complicated in some dynamic views.
You obviously want something more advanced than just editing the 404 template in the errors folder. I've had problems trying to access get_instance() from that file, as sometimes it's loaded before the controller is constructed. So, be careful if you try that ;)
Update: Here's a working example of extending the show_404() function to load a view
<?php
// application/core/MY_Exceptions.php
class MY_Exceptions extends CI_Exceptions {
public function show_404()
{
$CI =& get_instance();
$CI->load->view('my_notfound_view');
echo $CI->output->get_output();
exit;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…