if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->redirect(['panel/home/index']);
}
代码如上很简单,就是登录验证通过就redirect到http://host/panel/home/index
,但是在本地和测试服务器上正常跳转了,在正式服务器上却会产生了网页刷新的动作却没有跳转到http://host/panel/home/index
,我在return $this->redirect(['panel/home/index']);
前加上echo"success";die();
后成功输出了success,说明的确是运行到了redirect这里的,但是为什么会正式服务器上无法跳转?
两个环境服务器配置不一样。
试试
header(“Location:$url”);exit;
试试
return $this->redirect(‘panel/home/index’);
试试 return $this->redirect(['/panel/home/index']);
多了一个斜杠。
打开浏览器,切换到调试中的“network”看看 response中的header中是否有重定向302的状态码