kohana-3.3

Routing in Kohana without showing controller name


I want to create a routing in Kohana Framework Version 3.3.1.

I want URL like http://www.test.com/male/London and internally they will act like below URL-

http://www.test.com/list/search/London

I want to hide the controller and action name from the URL.

Any help is greatly appreciated.


Solution

  • This can be accomplished by using routes in bootstrap.php and/or a module's init.php file.

    For example, you could set up a route for (male/<location>) and then your default controller would be list and the action search.

    You could then access the location within the controller/action by using $this->request->param('location'); to be used in whatever DB query you need it.

    Confused? Have a read through this section of Kohana Docs and it should all make sense.