Search code examples
phphttp-redirectactionzend-framework2

Zend Framework 2 - Redirector action helper


I've googled for quite a while but couldn't come up with a working solution for my problem.

When going to my website the user sees a login screen. My ZFCUser forwards the user to my Application/index action. From there I want a "junction" which redirects regular users to one action and backend/admin users to another.

In ZF1 it seems that there were this Redirector helper...?

Does anybody know a way to achieve what I want to do? Or maybe tell me a more Zend-y way of doing this?


Solution

  • You can use the redirect controller plugin in your action like this:

    return $this->redirect()->toRoute('user-page');
    

    user-page is the key of a defined route

    OR

    return $this->getController()->redirect()->toUrl("http://www.mysite.com");