Managing URLs in the standard way in a Codeigniter-HMVC project

I developed the project in codeigniter-HMVC, now I want to manage URLs in a standard way.

My current urls are:

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

I want just:

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

I use the HMVC coding structure.

+4
source share
3 answers

You can define custom routes in routes.php

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

In a url xyz/contact-us'that will work fine

More on CodeIgniter Route

+2
source

In ur ​​route.php u file can be redirected as

$route['xyz/contactus'] = "xyz/home/contactus";
+1
source

routes.php [project-folder]/application/config/routes.php

URI , . URI , URL- , , .

$route['dummy-controller/dummy-method'] = 'main_controller/main_method';

$route['contact-us']='index.php/home/contactus';

0
source

Source: https://habr.com/ru/post/1693962/


All Articles