![]() |
URI Mapping to another controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: URI Mapping to another controller (/showthread.php?tid=49920) |
URI Mapping to another controller - El Forum - 03-07-2012 [eluser]Unknown[/eluser] Hi, I wish to map the URI to another controller, however CI can only access the index() method, while calling other method in the mapped controller, it will give me a 404 error. Example: Quote:example.com/admin Everything works as it is. there is a controller for "admin") But I wish to map the following URI to its controller. Example: Code: example.com/admin/users But, so far CI would only show "users" controller's index() method to me. but if I tried to access other functions defined in "users" controller (in this example : test() method) Code: example.com/admin/users/test here is my current Routes.php's configuration: Code: $route['admin/user'] = "user"; Any help would be appreciated! Thanks! URI Mapping to another controller - El Forum - 03-07-2012 [eluser]douweegbertje[/eluser] you have to understand that your controller works like this: example.com/admin/ Code: <?php example.com/admin/users Code: <?php and: example.com/admin/users/10 Code: <?php URI Mapping to another controller - El Forum - 03-07-2012 [eluser]Unknown[/eluser] [quote author="douweegbertje" date="1331139399"] you have to understand that your controller works like this: example.com/admin/ Code: <?php example.com/admin/users Code: <?php and: example.com/admin/users/10 Code: <?php Yes, I do understand this. But it did not make sense if I wrote all my code in to "admin" controller, Right ? I have separate controller (in this case "users") that deal with managing users data. But I did not wish the user knew it was accessible through Code: example.com/users It would be great to be able to map the calls to the separate controller if possible, so the code will be less clutter and easy to maintain. ( Sorry, first time PHP coder, things can get really messy in codes. ![]() |