Welcome Guest, Not a member yet? Register   Sign In
routing and pagination problem

Hi, I'm new to codeigniter. I've read URI Routing manual and this thread. I have the same problem like that thread, I want to remove 'index' from the URI (http://localhost/igniter/hello/index/10) to (http://localhost/igniter/hello/10).

URI routing doesn't work for me so I use _remap function, but it made pagination doesn't works. If I press page 2, it keeps bold at page 1.

My question:
Is there something I need to do to activate the routing or fix the pagination when using _remap function?

I already tried to change
$config['uri_protocol']    = "AUTO";
QUERY_STRING and ORIG_PATH_INFO makes the page redirected to welcome page, others are just 404 not found error.

I also already change index_page to blank
$config['index_page'] = "";

htaccess code
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Here's the controller code
class Hello extends Controller {

    function __construct()
        //$route['hello/:any'] = "hello/index/$1";
        //$route['hello/10'] = "hello/index/10";
        //$route['(:any)/'] = "hello";
    public function _remap($strMethod='index')
        call_user_func_array(array(&$this, 'index'), array_slice($this->uri->segment_array(), 2));
    function index()
        $page_limit = 10;
        $segmen = $this->uri->segment(2,0);
        $data['query'] = $this->hellomodel->get_entry("category", $segmen, $page_limit);
        //$config['base_url'] = base_url().'hello/index/';
        $config['base_url'] = base_url().'hello/';
        $config['total_rows'] = $this->db->count_all('category');
        $config['per_page'] = $page_limit;
        echo $this->pagination->create_links();
        $this->load->view('helloview', $data);


I solved the pagination problem by looking at this thread.

I also already solved the routing, I put the route at config/routes.php.. Is there some way I can put the route in the controller?

[eluser]Cesar Kohl[/eluser]
I had the same problem. The solution is surprisingly simple:

$config['uri_segment'] = 2;

.. in the pagination config file I hope you created.

Theme © iAndrew 2016 - Forum software by © MyBB