htaccess的Codeigniter 3分页不起作用

Kaustubh Lohiya

我正在尝试在Codeigniter 3中实现分页,但是它始终会显示404页面未找到错误。我正在使用htaccess文件隐藏index.php。

我的控制器功能是

$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'] = '&nbsp;<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;

我之前在Codeigniter 2的另一个项目中使用了相同的代码,并且可以正常工作。请让我知道这有什么问题

任何帮助将不胜感激。

谢谢

阿卜杜拉·尼拉姆(Abdulla Nilam)

改变这些

$config['base_url'] = base_url().'gallery';
$config['uri_segment'] = '1';
if($this->uri->segment(1))
{
    $page = ($this->uri->segment(1)) ;
}

您的代码中有冲突

$config['uri_segment'] = '4';

if($this->uri->segment(2))
{
    $page = ($this->uri->segment(2)) ;
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

分页在Codeigniter 3上不起作用

来自分类Dev

Codeigniter分页不起作用

来自分类Dev

.htaccess在Codeigniter中不起作用

来自分类Dev

.htaccess在Codeigniter中不起作用

来自分类Dev

.htaccess在Codeigniter中不起作用

来自分类Dev

codeigniter htaccess php指令不起作用

来自分类Dev

Codeigniter分页和.htaccess

来自分类Dev

bootstrap 3分页与codeigniter

来自分类Dev

bootstrap 3分页与codeigniter

来自分类Dev

由于htaccess规则,分页不起作用

来自分类Dev

Codeigniter URL重写.htaccess在CentOS上不起作用

来自分类Dev

.htaccess在Mac OS上的CodeIgniter项目中不起作用

来自分类Dev

Codeigniter ajax分页搜索结果不起作用

来自分类Dev

分页在 codeigniter 中不起作用,找不到 404 页面

来自分类Dev

为什么在 CodeIgniter 中分页链接对我不起作用?

来自分类Dev

Laravel 4.2分页不起作用

来自分类Dev

Codeigniter 3中的论点不起作用

来自分类Dev

通过.Htaccess进行URL重定向在Php Codeigniter中不起作用

来自分类Dev

.htaccess从一页到另一页的重写规则不起作用

来自分类Dev

单击其他页面链接时,Codeigniter分页不起作用

来自分类Dev

htaccess评论不起作用

来自分类Dev

.htaccess RewriteEngine不起作用

来自分类Dev

htaccess RewriteCond不起作用

来自分类Dev

.htaccess重写不起作用?

来自分类Dev

.htaccess AddType不起作用

来自分类Dev

htaccess redirectaion不起作用

来自分类Dev

htaccess RewriteRule不起作用

来自分类Dev

CodeIgniter路由不起作用

来自分类Dev

AllowOverride不起作用-CodeIgniter