简体   繁体   中英

Redirect from default controller to HMVC modules controller in codeigniter

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.

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';

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

to

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

in your routes file.

and try

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM