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.

Should the URL change in the browser?

Hi there,

I have the following code:

class ControllerBase extends \Phalcon\Mvc\Controller
     * Kicks in before a route is executed
     * @param $dispatcher
     * @return bool
    public function beforeExecuteRoute($dispatcher)
        if (!$this->session->has('user')) {
            if ($dispatcher->getControllerName() == 'login' && $dispatcher->getActionName() == 'new'
                || $dispatcher->getActionName() == 'create') {
                'controller' => 'login',
                'action' => 'new'
            return false;

When the above code is triggered, I would expect the URL in the browser to say something like but instead, it says

Obviously, based on the above beforeExecuteRoute code, when the initial page is loaded (, there isn't a session item called 'user' and therefore it correctly forwards to login/new. However, I expect the URL in the browser to change? Am I misunderstanding something here? Is my beforeExecuteRoute wrong?

Any advice much appreciated.


In my application I use $this->response->redirect("login/new"); The forward method keeps the user at the some URL, but renders your "forward"-controller

forward only forwards the request internally to your application. $this->response->redirect() actually forwards the user.


Thanks guys. That explains it nicely :)