我是CodeIgniter的新手,遇到URL
问题。当我打开像www.abc.com/france
这样的网址时,它工作正常,但当网址打开www.abc.com/united_state
时,页面会打开,但页面的所有内容都没有正确显示。分页也不起作用(仅显示单页)。我的控制器代码是
$searchkey =$this->uri->segment(3);
$searchkey = urldecode(str_replace('_',' ',$searchkey));
$checkin =$this->uri->segment(4);
$checkout = $this->uri->segment(5);
$newkey=$this->uri->segment(5);
}
if(preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $checkin) && preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $checkout))
{
//echo "hello";
$last1=$last1+2;
switch($last1)
{
case 5:
$searchkey=$this->uri->segment(3);
$column = "CountryName";$master = "country";$master2 = "CountryName";
$getdata = $this->searchdata_model->get_listing_data_list($column,$searchkey,$checkin,$checkout,$master,$newkey);
$latest_listing = $this->searchdata_model->get_lastest_properties($searchkey,$master2);
$data['latest_listing'] = $latest_listing;
break;
我认为问题在于preg_match函数。
答案 0 :(得分:1)
允许config/config.php
文件中的下划线字符
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';