Search engine friendly URLs in CakePHP
Just want to share this piece of code I used to create a search friendly url on the Glued! project. If you want to create a URL in the form http://www.domain.com/users/user-1234.html where 1234 is the uid. Go to <your application>
Router::connect('/users/user-([0-9].*).html’, array(’controller’ => ‘users’, ‘action’ => ‘view’));
This of course assumes you have an action ‘view’ in your ‘users controller’. Something like:
function view($id){
// your code here
}
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.










I like this neat little trick. Thanks!