i am working on a Cakephp 2.x.. i want to remove the action or controller name from url ... for example i am facing a problem is like that
i have a function name index on my Messages controller in which all the mobile numbers are displaying
the url is
www.myweb.com/Messages
now in my controller there is a second function whose name is messages in which i am getting the messages against the mobile number
so now my url becomes after clicking the number is
www.myweb.com/Messages/messages/823214
now i want to remove the action name messages because it looks weired... want to have a url like this
www.myweb.com/Messages/823214
REST Routing
The example in the question looks similar to REST routing, a built in feature which would map:
To enable rest routing just use
Router::mapResources('controllername');
Individual route
If you want only to write a route for the one case in the question it's necessary to use a star route:
Usage:
This has drawbacks because it's not possible with this kind of route to validate what comes after
/messages/
. To avoid that requires using route parameters.Usage:
When connecting routes using Route elements you may want to have routed elements be passed arguments instead. By using the 3rd argument of Router::connect() you can define which route elements should also be made available as passed arguments:
and you can also refer link above given by me, hope it will work for you.
let me know if i can help you more.
in config/routes.php
You can use CakePHP's Routing Feature. Check out this page: http://book.cakephp.org/2.0/en/development/routing.html