Redirect On Beforeaction()

Hello guys!

Just a simple question, it’s possible to redirect in beforeAction()? Im trying to do a simple test but im always getting “Error 310 (net::ERR_TOO_MANY_REDIRECTS)”. The accessRules are set for the action and the urlManager is set to use path format.

So, i can’t do something like:




public function beforeAction($action)

{

    $this->redirect(array('site/test'));

    return parent::beforeAction($action);

}



Hi @RSfTDL

Your code redirects again and again because before running of site/index action executed the beforeAction over and over,

So you have to


public function beforeAction($action)

{

if ($action != 'test')

    $this->redirect(array('site/test'));

    return parent::beforeAction($action);


}

But what exactly you want to do?

Hi KonApaz!

Well, i was testing one thing that i had in mind but probably i’m going to use urlManager.

Thank you for your time!