Gediminas Šukys
Gediminas Šukys

Reputation: 7391

CakePHP routes with sub-folders

I have a problem with CakePHP route

Router::connect(
    '/catalog/:slug/:slug2/*', array(
        'controller'=>'pages', 
        'action'=>'view'
))

When I have url /catalog/something/page:2 - it also catches this link. But it shouldn't, because there is no slash after params page:2, How to fix it? Thanks!!

Upvotes: 0

Views: 697

Answers (1)

Anil kumar
Anil kumar

Reputation: 4177

I hope this may be helpful.

Router::connect(
    '/catalog/:slug/:slug2/*', array(
        'controller'=>'pages', 
        'action'=>'view'
), array('pass' => array('slug', 'slug2')));

and in your view file you can write like this to generate a link for above.

echo $this->Html->link('link', array(
    'controller' => 'pages',
    'action' => 'view',
    'slug' => 'slug',
    'slug2' => 'slug2'
));

Upvotes: 1

Related Questions