views:

40

answers:

1

hi,

I have started using cakePHP and have a little problem using routes. I'm trying to make some kind of catalog for products (e-shop without shopping :)) and like to have urls like "http://site.net/main_category/subcategory/subsubcategory-c154.htm" where -c means category and 154 is an Id of specified category. I like to pass this type of URLs to one controller, say CategoriesController but the route:

Router::connect('/:categoryUrl',
                array(
                    'controller' => 'categories',
                    'action'=> 'display'
                ),
                array(
                    ':categoryUrl' => '(.*)-c([0-9]+).htm'
                )
            );

doesn't working. It keeps searching for "main_category" controller as main_category is after first slash.

Have you guys (ladies too of course ;)) have some idea?

Thank's a lot kraklin

A: 

You probably need to escape the hyphen. It's listed as one of the characters escaped by preg_quote(). And you definitely need to escape the dot.

'(.*)\-c([0-9]+)\.htm'
mwhite