CodeIgniter Forums

Full Version: [NEED URGENT HELP] All controllers showing 404 except default controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
Can you access the other controllers when calling their URL directly?
move: $route['(:any)'] = 'home/$1'; to the end of your list of routes.
(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
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.
(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'
Can you able to access directly?
example.com/index.php/controller/method
Just blind guess - Try to add "RewriteBase /" to your .htaccess file:
Code:
RewriteEngine On
RewriteBase /
...

Or try any of these:
.htaccess for CodeIgniter
Do you have mod_rewrite enable in apache?
(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'
Pages: 1 2