Question

I'm trying to create a Route in Cakephp that can have anything as a prefix. But I also want the admin route to work properly. The prefix would in this case be a language. The Route has to link to a controller named front with action: index.

A url should look like this www.domain.com/eng/the/rest/of/the/url_12 or www.domain.com/nl/the/rest/of/the/url_12

This is what I have, wich means that I have to create a route for each language, and thats not what I want.

Router::connect('/', array('controller' => 'front', 'action' => 'index'));
Router::connect('/admin', array('controller' => 'cms', 'action' => 'index', 'admin' => true));
Router::connect('/nl/*', array('controller' => 'front', 'action' => 'index'));
Was it helpful?

Solution

You can use this:

Router::connect('/:i10n/:controller', array('action' => 'index'), array('i10n' => '[a-z]{2}'));
Router::connect('/:i10n/:controller/:action/*', array(), array('i10n' => '[a-z]{2}'));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top