S G
S G

Reputation: 13

How can I manage two different routings for a single given user in CakePHP?

For example :

Router::connect(
    '/:username', 
    array('controller' => 'users', 'action' => 'profile'),
    array('pass' => array('username'))
);

If the username parameter is prefixed by @, then it will redirect to a method. If not, it will redirect to different method.

Note : I'm using version 2.8

Upvotes: 1

Views: 43

Answers (1)

Inigo Flores
Inigo Flores

Reputation: 4469

This should work:

Router::connect(
    '/@:username', 
    array('controller' => 'users', 'action' => 'action1'),
    array('pass' => array('username'))
);

Router::connect(
    '/:username', 
    array('controller' => 'users', 'action' => 'action2'),
    array('pass' => array('username'))
);

Upvotes: 1

Related Questions