Search code examples
phpcodeignitercodeigniter-2codeigniter-3

Managing URLs in a standard way in Codeigniter-HMVC project


I have developed project in codeigniter-HMVC, now I want to manage urls in standard way.

MY current URLs:

http://xyz/home/contactus
http://xyz/home/aboutus
....
....

I want just like:

http://xyz/contactus
http://xyz/aboutus
....
....

I am using HMVC codeigniter structure.


Solution

  • You can define custom routes in routes.php

    $route['contact-us'] = "home/home/contactus";
              ^              ^     ^        ^
            New URL      module  Controller  Method
    

    In URL call xyz/contact-us' which will work fine

    Read more about CodeIgniter route