phpcodeignitercodeigniter-hmvc

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.


Solution

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