CodeIgniter Forums
[NEED URGENT HELP] All controllers showing 404 except default controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [NEED URGENT HELP] All controllers showing 404 except default controller (/showthread.php?tid=61783)

Pages: 1 2


[NEED URGENT HELP] All controllers showing 404 except default controller - webdevron - 05-16-2015

I am using these route setting to route through my app. It is working without any error on my localhost but on my online server I can access only the main controller and its methods and the rest of the controllers showing "404 ERROR" page. Please help me to get rid from this issue.

PHP Code:
$route['default_controller'] = "home";

$route['(:any)'] = 'home/$1';    // http://example.com/any
$route['load/(:any)'] = 'home/load/$1';  // http://example.com/load/any

$route['student'] = 'student';  // http://example.com/student
$route['student/(:num)'] = 'student/profile/$1';  // http://example.com/student/1234

$route['admin'] = 'admin';  // http://example.com/admin
$route['admin/(:any)'] = 'admin/$1';  // http://example.com/admin/any 

My .htaccess code is here

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Thanks in advance.


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - taskone - 05-16-2015

Can you access the other controllers when calling their URL directly?


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - Hobbes - 05-16-2015

move: $route['(:any)'] = 'home/$1'; to the end of your list of routes.


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - webdevron - 05-16-2015

(05-16-2015, 03:53 AM)taskone Wrote: Can you access the other controllers when calling their URL directly?



Not at all. These are my home controller sections-
example.com
example.com/faculty-member
....
....

My other controllers are Student, Admin, Act- (These are not working)
example.com/student
example.com/student/profile
example.com/admin


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - InsiteFX - 05-16-2015

As Hobbes mentioned all Any routes need to be the last ones in your routes file because they are a catch all route.

So if you have these routes
PHP Code:
$route['(:any)'] = 'home/$1';    // http://example.com/any

$route['student'] = 'student';  // http://example.com/student 


Your student route will never run because the any catch all route will always run.


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - webdevron - 05-16-2015

(05-16-2015, 04:02 AM)Hobbes Wrote: move: $route['(:any)'] = 'home/$1'; to the end of your list of routes.

Here it is, but same result-



PHP Code:
$route['act/load/(:any)'] = 'act/load/$1';

$route['student'] = 'student';
$route['student/(:num)'] = 'student/profile/$1';

$route['admin'] = 'admin';
$route['admin/(:any)'] = 'admin/$1';

$route['(:any)'] = 'home/$1'



RE: [NEED URGENT HELP] All controllers showing 404 except default controller - karthik_code - 05-16-2015

Can you able to access directly?
example.com/index.php/controller/method


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - Muzikant - 05-16-2015

Just blind guess - Try to add "RewriteBase /" to your .htaccess file:
Code:
RewriteEngine On
RewriteBase /
...

Or try any of these:
.htaccess for CodeIgniter


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - taskone - 05-16-2015

Do you have mod_rewrite enable in apache?


RE: [NEED URGENT HELP] All controllers showing 404 except default controller - webdevron - 05-16-2015

(05-16-2015, 05:25 AM)InsiteFX Wrote: As Hobbes mentioned all Any routes need to be the last ones in your routes file because they are a catch all route.

So if you have these routes

PHP Code:
$route['(:any)'] = 'home/$1'   // http://example.com/any

$route['student'] = 'student' // http://example.com/student 


Your student route will never run because the any catch all route will always run.

No result, here it is-

$route['act/load/(:any)'] = 'act/load/$1';

$route['student'] = 'student';
$route['student/(:num)'] = 'student/profile/$1';

$route['admin'] = 'admin';
$route['admin/(:any)'] = 'admin/$1';

$route['(:any)'] = 'home/$1'