我的路线是语言驱动的,看起来像这样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 中的数据库内容
我有一个名为posts的表,它包含标题、slug 和语言的内容行,但我不完全了解如何编辑我的主控制器以检查 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);
}
}
}