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?


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:

// ......


Read this part in the manual.



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



All Articles