如何重定向到 zend framework 2 中的主页(默认页面)?
How to redirect to Home page (Default page) in zend framework 2?
我在名为 "Authentication" 的模块中。使用此模块成功登录后,我希望我的用户重定向到主页(默认页面)。
我尝试了以下路线。但是没用。
$redirect = '/' ;
//$redirect = '' ;
//$redirect = null ;
return $this->redirect()->toRoute($redirect);
生成以下错误
Route with name "" not found
我不知道的另一个模块中没有定义主页路线。那么如何重定向到主页?
如果你分不清你的家乡路线名称,你至少有两个选择:
- 使其可配置 — 将主路由名称放入您的 module/application 配置中并在控制器中检索它。
只需重定向到 /
:
return $this->redirect()->toUrl('/');
我在名为 "Authentication" 的模块中。使用此模块成功登录后,我希望我的用户重定向到主页(默认页面)。
我尝试了以下路线。但是没用。
$redirect = '/' ;
//$redirect = '' ;
//$redirect = null ;
return $this->redirect()->toRoute($redirect);
生成以下错误
Route with name "" not found
我不知道的另一个模块中没有定义主页路线。那么如何重定向到主页?
如果你分不清你的家乡路线名称,你至少有两个选择:
- 使其可配置 — 将主路由名称放入您的 module/application 配置中并在控制器中检索它。
只需重定向到
/
:return $this->redirect()->toUrl('/');