I've been setting up some routes like this:
Router::connect('/background/a-page', array('controller' => 'background', 'action' => 'a_page'));
Router::connect('/background/another-page', array('controller' => 'background', 'action' => 'another_page'));
Router::connect('/background/my-third-page', array('controller' => 'background', 'action' => 'my_third_page'));
// More routes here
I would like to replace them with a route like this:
Router::connect('/background/:action', array('controller' => 'background'));
where the url /background/my-third-page
would map to the action my_third_page
(in the background controller). Note that the url has dashes and the action has underscores.
Currently Cake fails to map the conversion from dashes to underscores, so with my new route this fails: /background/my-third-page
but this works: /background/my_third_page
I want to keep dashes in the urls. Is there any way to make Cake map the dashes to underscores?
I'd also like the reverse routing to map from underscores to dashes, so:
$this->Html->link('View',
array('controller' => 'background', 'action' => 'my_third_page')
);
would map to: background/my-third-page
.
Thanks!