0
我想在Codeigniter 3中实现分页,但它始终给404页找不到错误。我正在使用htaccess文件来隐藏index.php。Codeigniter 3与htaccess分页不工作
我的控制器功能是
$config = array();
$config['base_url'] = base_url('gallery');
$total_row = $this->gallery_model->record_count();
$config["total_rows"] = $total_row;
$config["per_page"] = 5;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['uri_segment'] = '4';
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
if($this->uri->segment(2))
{
$page = ($this->uri->segment(2)) ;
}
else
{
$page = 1;
}
$data["results"] = $this->gallery_model->fetch_data($config["per_page"], $page);
.htaccess的是如下
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /lifeschool-genius/
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$/[L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
# RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
# RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
# Enforce NO www
# RewriteCond %{HTTP_HOST} ^www [NC]
# RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
我的路线文件
$route['(:any)'] = "welcome/$1";
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
我曾与笨2之前使用相同的代码在另一个项目它用于正常工作。请让我知道这有什么问题
任何帮助将不胜感激。
感谢
阅读这两个环节可以帮助你http://w3code.in/2015/10/how-to-do-pagination-in-codeigniter/和http://w3code.in/2015/ 09 /如何去除的指数的PHP文件从 - 笨-URL / – Ricky