Redirect to login page instead of index page in 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.phpand 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 中的索引页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:重定向到登录页面而不是 Yii 中的索引页面
基础教程推荐
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- php中的foreach复选框POST 2021-01-01
- php中的PDF导出 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
