Search code examples
cakephproutesdefaultprefix

CakePHP Routing, using a language prefix with a default prefix


I'm trying to create a routing prefix that would be default.

http://localhost/heb/mycont would leave to the Hebrew page, while

http://localhost/mycont would lead to the English page.

Router::connect('/:language/mycont',array('controller'=>'contname','action'=>'index'),array('language'=>'[a-z]{0,3}'));

This code allows me to use 0-3 letters for language, but it still requires a language!

http://localhost/a/mycont would work

http://localhost/mycont doesn't work

Any ideas how to fix that? Is it even possible with the default routing?


Solution

  • My solution was simply to setup the / to a specific language, while everything else is marked /:language/

    That way I did not make duplicated routes.