Question

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.

Was it helpful?

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

OTHER TIPS

None of these worked, but I did this instead:

At the end of my controller I put this:

$this->output->set_status_header('200');

and actually though that worked, the problem turned out to be a controller name that conflicted with a real directory name...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top