We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Redirects at webfaction not working

Hey there,

my problem is as follows: I develop my application a Vagrant VM using PHP 5.5, Apache 2 and Phalcon 1.3.0. I host my staging stuff in webfaction account, which is one of the few hosters to support Phalcon/which allows you to compile it yourself. Both environments use PHP 5.5 and Phalcon 1.3.0.

To login/logout in my backend, I use the following no-brainer-code. Locally, this works flawless. I also remember it worked at fortrabbit (can't verify atm). At webfaction, however, the redirects all result in a white page with error 500 in the console. The webfaction error logs don't contain anything, though. I am completely lost. Does anyone have an idea what could be the issue? :(

Edit: I noticed that what works is dispatcher->forward, but not response->redirect. But I don't want to internally forward all the time, if it can be avoided.

/**
 * Login for the users
 *
 * @return \Phalcon\Http\Response
 */
public function loginAction()
{
    Tag::appendTitle("Login");
    $form = new Login();

    if ($this->request->isPost()) {
        if ($form->isValid($this->request->getPost())) {
            try {
                $this->auth->check(
                    array(
                        'username' => $this->request->getPost('username'),
                        'password' => $this->request->getPost('password')
                    )
                );
                // Disable view to prevent invisible output of session flashes
                $this->view->disable();
                $this->flashSession->success('Welcome back!');
                $this->response->redirect(['admin', 'index']);
            } catch (Exception $e) {
                $this->flashSession->error($e->getMessage());
            }
        } else {
            foreach ($form->getMessages() as $message) {
                $this->flashSession->error($message->getMessage());
            }
        }
    }

    $this->view->form = $form;
}

/**
 * @return \Phalcon\Http\Response
 */
public function logoutAction()
{
    $this->auth->remove();
    $this->view->disable();
    $this->flashSession->success('Goodbye!');
    $this->response->redirect();
}


940
Accepted
answer
edited Mar '14

shouldn't it be:

$this->response->redirect("admin/index");

instead of:

$this->response->redirect(['admin', 'index']);

Stupid me. Thanks!