in modules\administrator\components\AdminController:
class AdminController extends CController
{
public function filters()
{
return array('accessControl');
}
public function accessRules()
{
return array(
array('deny', 'users' => array('*')),
);
}
}
in modules\administrator\controllers\Sitecontroller:
class SiteController extends AdminController
{
public function actionIndex()
{
$this->render('index');
}
public function actionLogin()
{
$this->render('login');
}
}
but when visit mydomain.site/administrator/site/index, it does not redirect to mydomain.site/administrator/site/login which redirects to mydomain.site/site/login (default login), I want it redirects to mydomain.site/administrator/site/login
can someone help me?
Set CWebUser::$loginUrl before filters are invoked:
Try this:
This way, when the url is requested for
site/index
and as we have setindex
to be allowed only for authenticated users, the request will be redirected tosite/login
(or default login).I hope it helps.