0
我已經設置了$路線[ '404_override'] = '城市/ switch_site'笨404_override
現在在我的城市控制器
級城市擴展是CI_Controller {
function __construct() {
parent::__construct();
}
function switch_site() {
$this->load->helper('url'); // load the helper first
$city = $this->uri->segment(1);
$segment_cnt = 1;
$valid_url = '';
switch($city) {
case 'pune':
$segments = $this->uri->segment_array(2);
foreach($segments as $value) {
if($segment_cnt > 1) {
$valid_url .= $this->uri->slash_segment($segment_cnt);
}
$segment_cnt++;
}
$this->config->set_item('cityid',1);
$this->config->set_item('cityname','pune');
echo APPPATH.'controllers/'.$valid_url;
include_once(APPPATH.'controllers/'.$valid_url);
break;
case 'mumbai':
$segments = $this->uri->segment_array(2);
foreach($segments as $value) {
if($segment_cnt > 1) {
$valid_url .= $this->uri->slash_segment($segment_cnt);
}
$segment_cnt++;
}
$this->config->set_item('cityid',2);
$this->config->set_item('cityname','mumbai');
include_once(APPPATH.'controllers/'.$valid_url);
break;
default:
}
}
}
我如何現在通過正確的URL codeigniter路由器
感謝您的答案,但我放棄了這個想法,而是使用codeigniter本地路由和pre_system鉤子來得到我需要的結果 – user160108 2011-04-23 05:10:48