我正在开发一个小型Web应用程序。在我的应用程序中,我遵循以下方法。
系统概述
我问了同样的问题,我修复并发布了答案: CodeIgniter Help - using multiple database on same application and issue with URI Routing
我的解决方案适用于CodeIgniter 2.X,但遗憾的是不适用于CodeIgniter 3.X。
如何在CodeIgniter 3.X中实现这一点?
答案 0 :(得分:0)
我找到了这个解决方案。
用此代码替换_validate_request函数。
protected function _validate_request($segments)
{
if(count($segments)===1)
{
$segments[0]='';
}
if(count($segments) > 1)
{
$x=$segments;
$a=1;
for($i=0;$i<(count($segments)-1); $i++)
{
$segments[$i]=$x[$a];
$a++;
}
unset($segments[$i]);
}
$c = count($segments);
// Loop through our segments and return as soon as a controller
// is found or when such a directory doesn't exist
while ($c-- > 0)
{
$test = $this->directory.ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]);
if ( ! file_exists(APPPATH.'controllers/'.$test.'.php') && is_dir(APPPATH.'controllers/'.$this->directory.$segments[0]))
{
$this->set_directory(array_shift($segments), TRUE);
continue;
}
return $segments;
}
// This means that all segments were actually directories
return $segments;
}