Redirect to login page instead of index page in Yii(重定向到登录页面而不是 Yii 中的索引页面)

本文介绍了重定向到登录页面而不是 Yii 中的索引页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我进入我的应用程序时,页面被重定向到 Yii 中的索引页面.

When I am going to my application, the page is redirect to the index page in Yii.

根据要求,我想像 /user/login 一样重定向到用户模块的登录页面.

As per requirement, I want to redirect to the login page of the user module just like /user/login.

为此,我已将 sitecontroller 代码索引更改为 user/login,但显示错误.

So for doing that I have changed the sitecontroller code index to user/login, but it showed an error.

有人能告诉我如何默认重定向 user/login 页面而不是索引页面吗?任何帮助和建议都将受到高度赞赏.

Can some one tell me how to redirect the user/login page by default instead of index page? Any help and suggestions will be highly appreciable.

推荐答案

检查 Yii 框架论坛上的这个主题.

复制/粘贴答案(由 jodev 提供):

Copy/paste of the answer (by jodev):

无需扩展任何东西.你所要做的就是敞开心扉protected/config/main.php 并将以下内容添加到配置数组中:

No need to extend anything. All you have to do is open up protected/config/main.php and add the following to the config array:

return array(
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => 'My application',
    'defaultController' => 'myController/myAction', // <--- add this line and replace with correct controller/action

这篇关于重定向到登录页面而不是 Yii 中的索引页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!