当我转到我的应用程序时,页面将重定向到Yii中的索引页面。
根据要求,我想重定向到用户模块的登录页面,就像/user/login
一样。
为此,我已将sitecontroller
代码索引更改为user/login
,但显示错误。
有人可以告诉我如何默认重定向user/login
页面而不是索引页面吗?任何帮助和建议都将非常值得一提。
答案 0 :(得分:16)
检查this thread on Yii framework forum。
复制/粘贴答案(通过 jodev ):
无需扩展任何内容。你所要做的就是开放
protected/config/main.php
并将以下内容添加到配置数组中:return array( 'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..', 'name' => 'My application', 'defaultController' => 'myController/myAction', // <--- add this line and replace with correct controller/action
答案 1 :(得分:0)
重定向到特定控制器/操作
$this->redirect(array('controller/action'));
在进入View及其表单之前,让我们清楚View如何访问特定模型。控制器可能有以下代码:
public function actionCreate() {
$model=new Employee;
/* Code for validation and redirect upon save. */
// If not saved, render the create View:
$this->render('create',array(
'model'=>$model, // Model is passed to create.php View!
));
}
答案 2 :(得分:0)
重定向到登录页面 $这 - &GT;重定向(阵列( '/站点/登录'));