嗨,我正在使用代码点火器,当我在浏览器中输入我的基本URL时,我想重定向到默认控制器。
我的基本网址
http://localhost/itams/index.php我的默认路线
$route['default_controller'] = "new_starter/listing";我的问题是当我在浏览器中输入http://localhost/itams/index.php时,它正确地重定向到new_starter/listing页面,但是浏览器URL没有改变。它显示为http://localhost/itams/index.php。
这是默认行为吗? 如何更改浏览器URL? 我必须使用
header()进行手动重定向吗?
提前谢谢。
发布于 2015-01-19 10:44:04
这是默认行为吗?
Ans。- YES
如何更改浏览器URL?
您需要将此代码放在默认控制器方法的开头。
if($this->uri->total_segments() === 0){
redirect('controller/method','refresh');
},即,在您的例子中,是new_starter控制器的listing方法。
最后它应该是这样的
Class New_starter extends APP_Controller {
...
public function listing(){
if($this->uri->total_segments() === 0){
redirect('new_starter/listing','refresh');
}
// rest of your method code.
}
...
}https://stackoverflow.com/questions/28020631
复制相似问题