我正在尝试对主页上的博客文章使用分页:
控制器:
public function index()
{
$data['view'] = "home";
/** Pagination **/
$config['base_url'] = base_url().'home/';
$config['total_rows'] = $this->Blog_model->count_articles();
$config['per_page'] = 2;
$config['uri_segment'] = 2;
$this->pagination->initialize($config);
$data['paginate'] = $this->pagination->create_links();
$data['articles'] = $this->Blog_model->get_articles($config['per_page'],$this->uri->segment(2));
$this->load->view('template', $data);
}
信息检索和分页似乎一切正常,但是,当我单击数字链接或下一个链接时,我收到 404 Not Found 错误。
我假设这与 URI 段有关?
正在加载的 URL 是第二页的http://www.example.com/home/2。