Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Redirecting 'contact-us' to ContactController is not working

I am using INVO example app from here:

I have copied all the files and set the db and base url.

It works, I can login etc.

however, I wanted to learn how to use redirects e.g.

I would like to use contact-us instead of contact without cahnging the name of the controller.

So, I created a file routes.php inside of the app/config folder and put this code inside routes.php :


$router->add('/contact-us', array(
    'controller' => "contact",
    'action' => "index"

However, it's not working and when I try to access http://localhost/test/contact-us I am getting this error:

You don't have access to this module

The original url http://localhost/test/contact works ok.

What am I doing wrong?

Do I need to set something else in Phalcon? Btw. how is the routes.php file loaded? Is it done automatically or do I need to set it somewhere? If so how?

edited Jul '14

I have kind of worked it out by changing the code to this:

$router = new Phalcon\Mvc\Router(true);

$router->add('/contact-us', array(
    'controller' => "contact",
    'action' => "index"

return $router;

Btw. notice that if you change Phalcon\Mvc\Router(true); to Phalcon\Mvc\Router(false); default routes will stop working, meaning the original default route:


will stop working (you won't be redirected to the ContactController) and you will end up on the INVO homepage.

And only the new route:


will be redirecting to the ContactController