views:

518

answers:

2

I need to redirect the default CakePHP home page / or (/pages/home) to /users/dashboard page I tried

Router::connect('/', array('controller' => 'users', 'action' => 'dashboard'));

and

Router::connect('/pages/home', array('controller' => 'users', 'action' => 'dashboard'));

But both are not working

A: 

You should be able to do this by simply replacing this part of app/config/routes.php:

/**
 * Here, we are connecting '/' (base path) to controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, /app/views/pages/home.ctp)...
 */
    Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));

.. with something like this:

/**
 * Here, we are connecting '/' (base path) to controller called 'Users' and
 * its action called 'dashboard' (ie. /users/dashboard)...
 */
    Router::connect('/', array('controller' => 'users', 'action' => 'dashboard'));

I sense a slight misunderstanding of the topic when you try to map from '/pages/home' to your dashboard. '/pages/home' only seems like the home page because there exists a route for that. If you want to change the homepage, you need to change the existing Router::connect('/', ...) rule. If you create a new rule for '/', underneath, it won't be executed as CakePHP will match the first route it finds.

deizel
Thanks deizel, thanks
Mithun P
A: 

your first attempt

Router::connect('/', array('controller' => 'users', 'action' => 'dashboard'));

Is the correct way to do it. If you are still having problems then there must be another issue.

What error do you see?

Felix
Yes, I got it, above one is correct.
Mithun P