0

Structure of my controller directory:

--Controller
  --frontend
    --user_controller

When i call default controller it says 404 page not found

Route i have set :

$route['default_controller'] = "frontend/user_controller";
$route['admin_panel/site'] = "site";
$route['admin_panel'] = "backend/admin_controller/dashboard";
$route['admin_panel/login'] = "backend/admin_controller/index";
$route['admin_panel/(:any)'] = "backend/admin_controller/$1";

$route['admin_panel/(:any)/(.*)'] = "backend/admin_controller/$1/$2";

And when i run http://localhost/example/frontend/user_controller then it works.

So but didn't work this url : http://localhost/example

Manish Tiwari
  • 1,806
  • 10
  • 42
  • 65
  • can you please provide more information as to the structure of your controller... Not enough to go on... The error is occurring as you are not calling the right place. is there a 'public function index()' in your user_controller? – Brian Ramsey May 11 '16 at 08:11
  • don't place the controller inside in folder if want to do you need some extra change. – Yaseen Ahmad May 11 '16 at 08:16
  • review this answer http://stackoverflow.com/questions/13955335/routing-controllers-in-sub-folders-codeigniter/13955395#13955395 – Yaseen Ahmad May 11 '16 at 08:20

3 Answers3

0

Please try with: move default controller at bottom

$route['admin_panel/site'] = "site";
$route['admin_panel'] = "backend/admin_controller/dashboard";
$route['admin_panel/login'] = "backend/admin_controller/index";
$route['admin_panel/(:any)'] = "backend/admin_controller/$1";

$route['admin_panel/(:any)/(.*)'] = "backend/admin_controller/$1/$2";
$route['default_controller'] = "frontend/user_controller";
0

Codeigniter will not allow default controller to be in a sub directory. You have to rewrite it as

$route['default_controller'] = "user_controller";

And place that directly in the controller folder

You can refer this thread to avoid this. But I didn't tested it.

It is better to avoid the core functionalities as it may affect the updates.

Community
  • 1
  • 1
Arun
  • 3,640
  • 7
  • 44
  • 87
0

I have not tested this but potentially you could use this to get around the sub-folder?

$route['frontend'] = 'frontend/user_controller';
$route['default_controller'] = 'frontend';

need to make sure there is a 'public function index()' in there though as you aren't specifying the method to load...

Brian Ramsey
  • 850
  • 7
  • 21