Reputation: 25701
I have my routes declared like this:
Router::connect('/profile/', array('controller' => 'accounts', 'action' => 'profile'));
Router::connect('/accounts/:action/*', array('controller' => 'accounts'));
Router::connect('/:username', array('controller' => 'accounts', 'action' => 'profile'), array('pass' => array('username')));
All my links are made with Cake's $html->url api call. The routes work fine when the url is just [domain]/accounts/profile and it gets rewritten correctly as [domain]/profile.
But when I make a link using $html->url(array('controller'=>'accounts', 'action'=>'profile', $username), true), the url write is [domain]/accounts/profile/:username and not just [domain]/:username.
How do I make it [domain]/:username?
Upvotes: 1
Views: 724
Reputation: 2432
try like so
Router::connect('/:username', array('controller' => 'accounts', 'action' => 'profile'), array('pass' => array('username')));
Router::connect('/profile/', array('controller' => 'accounts', 'action' => 'profile'));
Router::connect('/accounts/:action/*', array('controller' => 'accounts'));
Upvotes: 1