diff --git a/application/classes/controller/redir.php b/application/classes/controller/redir.php index fa22a2f..8589679 100644 --- a/application/classes/controller/redir.php +++ b/application/classes/controller/redir.php @@ -14,10 +14,15 @@ class Controller_Redir extends Controller { protected $auth_required = FALSE; public function action_index() { - $ro = ORM::factory('redir',array('servername'=>$_SERVER['SERVER_NAME'])); + // Try and find the path + $ro = ORM::factory('redir',array('servername'=>$_SERVER['SERVER_NAME'],'path'=>$this->request->param('id'))); - if (! $ro->loaded()) - $ro = ORM::factory('redir',0); + if (! $ro->loaded()) { + $ro = ORM::factory('redir',array('servername'=>$_SERVER['SERVER_NAME'],'path'=>NULL)); + + if (! $ro->loaded()) + $ro = ORM::factory('redir',0); + } $ro->count++; $ro->date_last_refer = time(); @@ -28,5 +33,9 @@ class Controller_Redir extends Controller { else $this->response->body(file_get_contents(Kohana::config('config.defaultfile'))); } + + public function action_path() { + return $this->action_index(); + } } ?> diff --git a/application/classes/http/exception/404.php b/application/classes/http/exception/404.php index 63946c5..9a00f19 100644 --- a/application/classes/http/exception/404.php +++ b/application/classes/http/exception/404.php @@ -25,6 +25,7 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 { 'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()), )); - // Request::factory()->redirect('welcome'); + // Redirect based on path info + Request::factory()->redirect('redir/path'.$_SERVER['PATH_INFO']); } }