• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[NEED URGENT HELP] All controllers showing 404 except default controller

#1
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.
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply

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

#3
move: $route['(:any)'] = 'home/$1'; to the end of your list of routes.
"I reject your reality and substitute my own" - Adam Savage, M5 Inc.
Reply

#4
(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
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply

#5
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
(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'
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply

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

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

Or try any of these:
.htaccess for CodeIgniter
Reply

#9
Do you have mod_rewrite enable in apache?
Reply

#10
(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'
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.