Added default 404 page
This commit is contained in:
@@ -31,25 +31,27 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
|
||||
|
||||
// Prepare the response object.
|
||||
$response = Response::factory();
|
||||
$redirect = $ro->redirect ? trim($ro->redirect) : Kohana::$config->load('config')->defaultfile;
|
||||
|
||||
// Process our redirection options
|
||||
if (is_null($redirect) OR ! trim($redirect)) {
|
||||
return parent::get_response();
|
||||
|
||||
} elseif (preg_match('/^http[s]?:\/\//',$redirect)) {
|
||||
if (preg_match('/^http[s]?:\/\//',$ro->redirect)) {
|
||||
$response->status(302);
|
||||
$response->headers('Location',$redirect);
|
||||
$response->headers('Location',$ro->redirect);
|
||||
|
||||
} elseif (preg_match('/^file:\/\/(.*)$/',$redirect,$matches) AND file_exists($matches[1])) {
|
||||
} elseif (preg_match('/^file:\/\/(.*)$/',$ro->redirect,$matches) AND file_exists($matches[1])) {
|
||||
$response->status(200);
|
||||
$response->body(file_get_contents($redirect));
|
||||
$response->body(file_get_contents($matches[1]));
|
||||
|
||||
HTTP::check_cache($this->request(),$response,sha1($response->body()));
|
||||
|
||||
$response->headers('Content-Type',File::mime_by_ext(pathinfo($matches[1],PATHINFO_EXTENSION)));
|
||||
$response->headers('Content-Length',(string)$response->content_length());
|
||||
$response->headers('Last-Modified',date('r',$matches[1] ? filemtime($matches[1]) : time()));
|
||||
|
||||
} else {
|
||||
$response->status(404);
|
||||
$response->body(View::factory('404'));
|
||||
|
||||
HTTP::check_cache($this->request(),$response,sha1($response->body()));
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
Reference in New Issue
Block a user