Should the URL change in the browser - Mk 2

Hi there,

Yesterday, I posted a question of the same title but after trying the resolution offered, I still get the same issue. The URL is changed to http://10.10.22.35/host%5ui/index instead of http://10.10.22.35/login/new - as you can see from the code below, I've changed my dispatch forward call to a response redirect. Any thoughts around this? Thanks.

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') {
                return;
            }
            $this->response->redirect('login/new');
        }
    }
}
edited Apr '14

I think you need some parentesis there, the && operator has higher precedence than the || operator:

if ($dispatcher->getControllerName() == 'login' && 
    ($dispatcher->getActionName() == 'new' || $dispatcher->getActionName() == 'create'))

otherwise that condition will be true for every route that has "create" as action



9.5k
edited Apr '14

edit/ only noticed this is from 5 days ago. Managed to fix it?

What is your htaccess and root directory? I found that phalcon likes being very anoying with multi-folder set ups, so it's best to keep every site in a separate virtual host pointed to the public folder, not root as suggested in docs.



22.6k

Hi @nazwa

Thanks for taking the time to check this out! :)

The simple answer is that thankfully, I've resolved the issue. The longer answer is that I learned much trying to resolve it!

On this occasion, I'm using Nginx so, that added an additional complication given that I was/am a lot more familiar with Apache. However, it's running well enough now so, fingers crossed! :)

Cheers.