在 Index 模块 index 方法中,重定向到本模块的 select 操作:
class IndexAction extends Action{ public function index(){ $this->redirect('select', array('status'=>1), 3, '页面跳转中~'); } }
重定向后得到的 URL 可能为:http://www.520mg.com/index.php/Index/select/status/1
由于该方法调用了 U 函数来生成实际的 URL 重定向地址,因此重定向后的 URL 可能因配置不同而有所不同:
隐藏了入口文件 index.php 的 http://www.520mg.com/Index/select/status/1 隐藏了入口文件 index.php 且设置了伪静态的 http://www.520mg.com/Index/select/status/1.html
一些常用的 redirect 重定向例子:
// 不延时,直接重定向 $this->redirect('select', array('status'=>1)); // 延时跳转,但不带参数,输出默认提示 $this->redirect('select', '', 3); // 重定向到其他模块操作 $this->redirect('Public/login'); // 重定向到其他分组 $this->redirect('Admin-Public/login');提示: