Added path based redirection

This commit is contained in:
Deon George 2011-09-13 16:58:59 +10:00
parent 88b915fd58
commit 46b2248c37
2 changed files with 14 additions and 4 deletions

View File

@ -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();
}
}
?>

View File

@ -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']);
}
}