-4

How to redirect from CI default controller to HMVC modules controller?

I have a fresh installation of CI, in which I have defined default controller in /application/config/routes.php

$route['default_controller'] = 'welcome';

Now I am trying to use complete modular way and write everything in modules directory. For that purpose I have created a home app in

/application/modules/home/controllers/Home.php

Now the issue I am having is, I am not able to directly redirect to my home page using localhost/ci

This url is redirecting to default welcome.php

When I pass localhost/ci/index.php/home I can navigate to home page.

I tried using redirect, it didn't work.

I want to redirect to home page using localhost/ci url. Please help.

Vijay Mishra
  • 350
  • 2
  • 14

2 Answers2

3

Change your default controller like this..

$route['default_controller'] = 'home';

if you want to redirect to particular method of your controller:Then

$route['default_controller'] = 'home/method_name';
Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19
0

just change your $route['default_controller'] = 'welcome';

to

$route['default_controller'] = 'folder_name/controller_name';

in your routes file.

and try

Ganesh Aher
  • 1,118
  • 3
  • 21
  • 51
  • what is your folder structure ? it should be "modules/folder_name/controllers/controller_name.php" . if you want run any specific method, then write that method after controller_name, otherwise just folder_name/controller_name(it runs index() function of that controller). – Ganesh Aher Feb 03 '17 at 09:11
  • Ok, you mean to say folder name is not modules, it should be actual app name. I got it. It works. I thought folder_name refers to the name of modules folder. Thanks for clarification. – Vijay Mishra Feb 03 '17 at 09:16
  • @Ganesh Aher no need to give `modules` folder name.HMVC by default takes all the controllers from folders. – Hikmat Sijapati Feb 03 '17 at 09:19