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

3
  • 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? Commented May 11, 2016 at 8:11
  • don't place the controller inside in folder if want to do you need some extra change. Commented May 11, 2016 at 8:16
  • review this answer stackoverflow.com/questions/13955335/… Commented May 11, 2016 at 8:20

3 Answers 3

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";
Sign up to request clarification or add additional context in comments.

1 Comment

It wouldnt, default can be at top no problems
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.

Comments

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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.