私は小さなWebアプリケーションに取り組んでいます。私のアプリケーションでは、次のアプローチに従います。
システムの小さな概要
私は同じ質問をし、答えを修正して投稿しました:CodeIgniterヘルプ-同じアプリケーションで複数のデータベースを使用し、URIルーティングで問題が発生する
私のソリューションはCodeIgniter2.Xで正常に機能していますが、残念ながらCodeIgniter3.Xでは機能していません。
CodeIgniter 3.Xでこれを実現するにはどうすればよいですか?
私はこの解決策を見つけました。
_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;
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加