default_controller (in routes.php) not working in production

走远了吗. 提交于 2019-12-13 02:13:26

问题


Regarding codeigniter routes.php :

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

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

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.

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.

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

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

回答1:


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.

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

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

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

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



来源:https://stackoverflow.com/questions/10958707/default-controller-in-routes-php-not-working-in-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!