CodeIgniter返回所有路线的404,但有效 [英] CodeIgniter returns 404 for all routes but works

查看:159
本文介绍了CodeIgniter返回所有路线的404,但有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对CodeIgniter和路由系统有一个奇怪的问题,无法找到解决方案,因此:我有几条路由,例如

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',

,它们可以工作,但在标头中返回404代码。

and them works, but return 404 code in header.

我的意思是我没有得到404页面,正确的HTML返回值以及页面内容正确显示在我的论坛类别中。但是我的标头中显示404(Firebug中的网络标签),因此我无法正确处理POST数据。

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.

如果我请求/ forum /-200确定返回,但是当我尝试获取路由页面时,我得到了正确的页面,但是找不到404。

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

我正在Linux主机上使用PHP5.4 + Apache2,如果能帮助您提供解决方案。

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

推荐答案

我找到了解决方案!

问题不在CodeIgniter中,我在激活mod_rewrite中找到了解决方案。是的,可以,但是不会在Apache中激活。

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

只需尝试

sudo a2enmod rewrite

并在

sudo service apache restart

并且所有路由的页面都将返回200 OK

And all routed pages will return 200 Ok

这篇关于CodeIgniter返回所有路线的404,但有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆