Yii redirect user / login

I am a Yii noob developer and I have an AdminController with access rules. So this controller is only enabled for certain users, otherwise it is redirected to "example.com/site/login", but I need it to be redirected to "example.com/user/login". So can you tell me how to do this?

+3


source to share


2 answers


You can change the property loginUrl

for a custom component, so make the following changes in the main.php config file:

array(
// ......
 'components'=>array(
    'user'=>array(
        'loginUrl'=>array('user/login'),
    ),
 ),
)

      



Read this part in the manual.

+7


source


In protected/config/main.php

where you define parameters for all other system components, you must define loginUrl

for the component user

:

....
'components' => array(
    'user' => array (
        'loginUrl' => array('/user/login'),
    ),
    ....
),
....

      



Docs: http://www.yiiframework.com/doc/api/1.1/CWebUser#loginUrl-detail

+2


source







All Articles