Search code examples
codeigniter-2codeigniter-url

CodeIgniter returns 404 for all routes but works


I have strange problem with CodeIgniter and routing system and can't find solution for it, so: I have several routes such as

'forum/(:num)'
    => 'forum/category/$1',
'forum/(:num)/(page:any)'
    => 'forum/category/$1/$2',

and them works, but return 404 code in header.

I mean I don't get 404 page, correct HTML returns and page's content displays correctly for my forum's categories. But I'm getting 404 in header (Network tab in Firebug), so I can't work with POST data correctly.

If I request /forum/ - 200 Ok returns, but when I trying to get routed page, I get right page, but with 404 Not Found.

I'm using PHP5.4+Apache2 on Linux host, if it will help You to give me solution.


Solution

  • I've found solution! Maybe it will save someone's time.

    Problem wasn't in CodeIgniter, I've found solution in activation mod_rewrite. Yes, that worked, but wan't activated in Apache.

    Just try to do

    sudo a2enmod rewrite
    

    and restart apache service after

    sudo service apache restart
    

    And all routed pages will return 200 Ok