<?php defined('SYSPATH') or die('No direct script access.');
try
{
echo Request::instance()
->execute()
->send_headers()
->response;
}
catch (Kohana_Exception $e)
{
echo Request::factory('static/404')->execute()->send_headers()->response;
}
404 action
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Static extends Controller_Template_Twig
{
public function action_404()
{
if (isset ($_SERVER['HTTP_REFERER']) AND strstr($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME']) !== FALSE)
{
$this->template->local = TRUE;
}
$this->template->page = url::site(Request::instance()->uri);
$this->request->status = 404;
}
}
1 comments:
If you don't feel happy about wrapping your request instance in a try... catch statement you can write your own exception handler, like I have with my Prophet module (https://github.com/DrPheltRight/Prophet) and Errorist by Mathew Davies (https://github.com/ThePixelDeveloper/kohana-bits-and-bobs/tree/master/modules/errorist).
The method described in this blog post handles all errors (not just page not found) as 404 errors!!
Post a Comment