私のルートは言語主導で、 mydomain.com /enのように見えます
$route['default_controller'] = "home";
$route['404_override'] = '';
$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];
しかし、 mydomain.com / jp/ the-slug-of-a-Japanese-pageという言語の後にURIに入れたいデータベースコンテンツがあります。
postというテーブルがあり、タイトル、スラッグ、言語を含むコンテンツの行が用意されていますが、ホームコントローラーを編集してURIがデータベースからのものかどうかを確認する方法が完全にはわかりません。
これが私のホームコントローラーの方法です。
class Home extends CI_Controller {
function __construct()
{
parent::__construct();
}
public function index($title = '') {
if(strlen($url)) {
/* get content by title from DB */
$data['url'] = $url;
$this->load->view('user_home', $data);
}
}
}