default_controller(在routes.php中)在生产中不起作用

问题描述:

关于codeigniter route.php:

Regarding codeigniter routes.php :

我们在C:\wamp\www\application\config\routes.php中有以下条目

We have following entry in C:\wamp\www\application\config\routes.php

$route['default_controller'] = 'latestC';
$route['404_override'] = 'latestC';

,而lastC是我们的默认控制器。这里default_controller在生产中不起作用。如果我们删除$ route ['404_override'] ='latestC'行;从routes.php中,我们无法在访问主URL mozvo.com及其404时到达主页。基本上,404_override代替了default_controller为我们工作,而是为我们完成了访问mozvo.com的主页。请求通过404_override控制器路由到主页。

and latestC is our default controller. Here default_controller is not working in production. If we remove line $route['404_override'] = 'latestC'; from routes.php, we are not able to reach to home page while hitting main url mozvo.com and its a 404. Basically 404_override is doing job for us instead of default_controller for taking to homepage on hitting mozvo.com. Requests are routing to home page by 404_override controller.

但是在localhost中,它运行良好。在localhost中,如果我们删除404_controller,则default_controller会处理主网址(mozvo.com,在此为localhost),而其他不受支持的网址则是404,这是正确的。但是在生产中,default_controller不能正确地进入主页(mozvo.com),因此我们*使用404_override将默认请求发送到主页。

But in localhost, it works perfectly. In localhost if we remove 404_controller, default_controller takes care of main url (mozvo.com, here localhost ) and others non supported urls are 404 which is correct. But in production default_controller is not taking to homepage(mozvo.com) properly so we are forced to use 404_override to take default request to homepage.

附加信息-C中的条目:\wamp\www\application\config\config.php

Additional Info - Entries in C:\wamp\www\application\config\config.php

$config['base_url']    = 'http://mozvo.com/';
$config['index_page'] = '';


我打赌你的问题是由于区分大小写在文件上。您的本地主机位于WAMP上-Windows不关心文件大小写。

I bet you the issue is due to case-sensitivity on files. Your local host is on WAMP - which windows does does not care about file cases.

即LatestC.php = Latestc.php = LASTESTC.php

i.e. latestC.php = latestc.php = LASTESTC.php

但是在您的生产服务器上(我猜这是一个LAMP)-区分大小写很重要

but on your production server (which I'm guessing is a LAMP) - case sensitivity DOES matter

即LatestC.php!= Latestc.php!= LASTESTC.php

i.e. latestC.php != latestc.php != LASTESTC.php

您的所有控制器的Codeigniter必须为小写。因此,将您的路线更改为

All your controllers must be LOWERCASE for Codeigniter. So change your routes to

$route['default_controller'] = 'latestc'; // all lowercase
$route['404_override'] = 'latestc'; //all lowercase

并确保所有文件均为小写

and make sure all your files are all lowercase