Welcome Guest, Not a member yet? Register   Sign In
Help with pagination and mod_rewrite(Solved)
#1

[eluser]fraserk[/eluser]
Hi Everyone. I'm creating my first project in codeigniter and have run into a little problem.

I think because I am using mod_rewrite to remove the index.php from my url the pagination is not working. When you click to go the the second page in the pagination link, it giving a 404 page not found error.

Pagnation Code in Controller

Code:
$config['base_url'] =  "http://www.goingclubing.com/";
            $config['total_rows'] = '20';
            $config['per_page'] = '10';
            $config['num_link'] = '2';
            $config['uri_segment'] = '3';
            
            $config['full_tag_open'] = '<div id="pag">';
            $config['full_tag_close'] = '</div>';
            $config['first_tag_open'] = '<div>';
            $config['first_tag_close'] = '</div>';
            $config['first_link'] = 'First';
            $config['last_link'] = 'Next';

Code in Model
Code:
$query = $this->db->get('events', 20, $this->uri->segment(3));
                 return $query->result();

htaccess Code

Code:
RewriteEngine on

RewriteCond $1 !^(admin/Promoters_admin\.asp|index\.asp|index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{QUERY_STRING} ^party_id=214$

RewriteRule ^party_detail\.asp$ http://www.goingclubing.com [R=301,L]


redirect 301 /index.asp http://www.goingclubing.com
redirect 301 /admin/Promoters_admin.asp http://www.goingclubing.com

Im not sure what I should I should use for the ['base_url'].

Thanks...
#2

[eluser]therealjerdev[/eluser]
[quote author="fraserk" date="1259856615"]Hi Everyone. I'm creating my first project in codeigniter and have run into a little problem.

I think because I am using mod_rewrite to remove the index.php from my url the pagination is not working. When you click to go the the second page in the pagination link, it giving a 404 page not found error.

Pagnation Code in Controller

Code:
$config['base_url'] =  "http://www.goingclubing.com/";
            $config['total_rows'] = '20';
            $config['per_page'] = '10';
            $config['num_link'] = '2';
            $config['uri_segment'] = '3';
            
            $config['full_tag_open'] = '<div id="pag">';
            $config['full_tag_close'] = '</div>';
            $config['first_tag_open'] = '<div>';
            $config['first_tag_close'] = '</div>';
            $config['first_link'] = 'First';
            $config['last_link'] = 'Next';

Code in Model
Code:
$query = $this->db->get('events', 20, $this->uri->segment(3));
                 return $query->result();

htaccess Code

Code:
RewriteEngine on

RewriteCond $1 !^(admin/Promoters_admin\.asp|index\.asp|index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{QUERY_STRING} ^party_id=214$

RewriteRule ^party_detail\.asp$ http://www.goingclubing.com [R=301,L]


redirect 301 /index.asp http://www.goingclubing.com
redirect 301 /admin/Promoters_admin.asp http://www.goingclubing.com

Im not sure what I should I should use for the ['base_url'].

Thanks...[/quote]



I'm definitely having the same problem.
Is there a fix?
#3

[eluser]CroNiX[/eluser]
base_url should be http://yoursite.com/controller/method/
Then it will add the page number to the 3rd segment for all paginated links
#4

[eluser]therealjerdev[/eluser]
[quote author="CroNiX" date="1393125370"]base_url should be http://yoursite.com/controller/method/
Then it will add the page number to the 3rd segment for all paginated links[/quote]

Wow thanks so much.
It finally works lol.

Does CodeIgniter mention that in its userguide/references?
Because I believe I haven't seen such documentation.
#5

[eluser]CroNiX[/eluser]
Yes, in the very first example, and just below that it says:
Quote:base_url This is the full URL to the controller class/function containing your pagination. In the example above, it is pointing to a controller called "Test" and a function called "page". Keep in mind that you can re-route your URI if you need a different structure.




Theme © iAndrew 2016 - Forum software by © MyBB