Paginating Search Results - 404 Error |
[eluser]mpar612[/eluser]
Hello, I am trying to implement pagination for the the first time. The code below works fine except for the pagination. The view page displays the appropriate number of search results and the page number links appear in the right place, but when I click on any of the page numbers I get " 404 Page Not Found The page you requested was not found." I have searched through the forums and am leaning towards this being a URI problem, but I have not found a resolution. Any assistance would be greatly appreciated. Thanks in advance! Controller: Code: class Basicidx extends Controller { Model: Code: class basicidx_model extends Model{ View: Code: <html>
[eluser]richwalkup[/eluser]
If you are getting 404 errors, it's related to how you have configured your CI setup. Either you do not have the proper .htaccess file in the public web root, it's improperly configured, or your web host doesn't support URL rewrites (uncommon and unlikely). Something unrelated that you want to look into is the constructor of your model class. It should be: Code: function basicidx_model(){ The way you currently have your constructor written, it is never firing and is not initializing the constructor of the base Model class and therefore not really working properly. Secondary to that, standard convention would have you name your model class Basicidx rather than basicidx_model, but as with most things in CI, it's just a suggestion, not a requirement.
[eluser]mpar612[/eluser]
Thanks for the tips! Is this the .htaccess file that I need to create in my websites root directory: http://codeigniter.com/wiki/mod_rewrite/? It belongs in the root directory of my website not within the system directory, right? Thanks again!
[eluser]richwalkup[/eluser]
[quote author="mpar612" date="1244785096"] Is this the .htaccess file that I need to create in my websites root directory: http://codeigniter.com/wiki/mod_rewrite/? It belongs in the root directory of my website not within the system directory, right? [/quote] Yes, that is the .htaccess file you would want to use and it does belong in the public document root.
[eluser]mpar612[/eluser]
Thanks! I added the .htaccess file and enabled mod_rewrite in my httpd.conf file and I am still getting 404 errors with pagination. Does anyone have any thoughts? Thanks!
[eluser]TheFuzzy0ne[/eluser]
Try changing the uri_protocol in your config.php. see if that helps. One of those options should work.
[eluser]mpar612[/eluser]
I tried each of the uri_protocol options and I still got 404 errors. Here is how I access my search from: http://www.domain.com/basicidx The search results are produced on: http://www.domain.com/basicidx The pagination links try to access this page: http://www.domain.com/basicidx/5 Does this seem right? Should the initial search results page include something like basicidx/#? Thanks in advance!
[eluser]TheFuzzy0ne[/eluser]
Does http://www.domain.com/basicidx work directly? If not, does it work like this: http://www.domain.com/index.php/basicidx |
Welcome Guest, Not a member yet? Register Sign In |