0
votes

In my cake application, I have a referral program for salespersons. For each signup the user can pass a referral id. Normally, my website has a default route which does the following:

//www.mydomain.com -> www.mydomain.com/pages/home
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));

Now I want to route to another controller/action like this:

//www.mydomain.com/r:1234 -> www.mydomain.com/users/signup/r:1234
Router::connectNamed(array('r'));
Router::connect('/*', array('controller' => 'users', 'action' => 'signup'));
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));

The routing for the signup works fine now, but the default route doesn't work anymore. I think the order is ok. Any ideas?

1
what does it means 'doesn't work anymore'? When you type www.mydomain.com are you noe redirected somewhere? - arilia
I’d use a query string parameter, which is the norm, i.e. example.com/?aff=foo. You don’t need to set up custom routes or whatever, and set a cookie or whatever in AppController::beforeFilter(). - Martin Bean
I wanted to do like this: www.mydomain.com/users/signup/r:1234, but I learned that I have to do it with a controller then it works. Like this www.mydomain.com/users/signup/r:1234. I did a route and have now this, which is also ok for me: www.mydomain.com/users/r:1234 - FishWave

1 Answers

0
votes

If i understood your issue than It should be look like this:

//www.mydomain.com/r:1234 -> www.mydomain.com/users/signup/r:1234
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/signup', array('controller' => 'users', 'action' => 'signup'));

Try this one.

Thanks