在继承了home的Index控制器设置了index和index2两个操作,当$utype==1时进入index2,但实现时却出现了死循环,这时候在if里再添加一个判断语句,判断此时所处的操作,可以解决这个问题,相关代码如下:
use think\facade\Request;
$action = Request::action();
if($utype==1){
if($action == 'index'){
$this->redirect('/index/index/index2');
}
}else{
if($action == 'index2'){
$this -> redirect('/index/index/index2');
}
}