我如何在 Yii 中的模块的 beforeControllerAction() 函数中进行重定向?
How can i do a redirect in beforeControllerAction() function from module in Yii?
我想在此函数中进行重定向。我该怎么做?
我尝试了以下方法:
$this->owner->redirect(array("/myurl"));
Yii::app()-request->redirect('/myurl');
$this->redirect('/myurl');
none 他们正在工作。
我试过 header('Location:myurl');它有效,但我不想在 Yii php 框架中使用 header。你我有什么想法吗?
$this->redirect(Yii::App()->request->baseUrl.'/myurl');
如果你想在控制器的动作中重定向,使用:
$this->redirect(Yii::app()->baseUrl.'/myurl');
$this
是您的控制器。
如果您想在其他地方重定向(例如在组件或扩展中),请使用:
Yii::app()->controller->redirect(Yii::app()->baseUrl.'/myurl')
我想在此函数中进行重定向。我该怎么做?
我尝试了以下方法:
$this->owner->redirect(array("/myurl"));
Yii::app()-request->redirect('/myurl');
$this->redirect('/myurl');
none 他们正在工作。
我试过 header('Location:myurl');它有效,但我不想在 Yii php 框架中使用 header。你我有什么想法吗?
$this->redirect(Yii::App()->request->baseUrl.'/myurl');
如果你想在控制器的动作中重定向,使用:
$this->redirect(Yii::app()->baseUrl.'/myurl');
$this
是您的控制器。
如果您想在其他地方重定向(例如在组件或扩展中),请使用:
Yii::app()->controller->redirect(Yii::app()->baseUrl.'/myurl')