Reputation: 490
I'm trying to make a redirect from route /admin to /admin/post/list.
I set a route from /admin to IndexController::indexAction()
Then I made controller like this
class IndexController extends AbstractActionController
{
public function indexAction()
{
$this->redirect()->toRoute('postList');
}
}
It works well, but ZF2 required to make a template index/index.phtml.
How I can do this redirect better, without empty templates?
Upvotes: 2
Views: 486
Reputation:
I found initially that I couldn't make the return response option work at all, in spite of the docs and plenty of abortive attempts.
In the end I stripped out the default application module that I had included to bootstrap things "out of the box" but wasn't using for anything else, and after shifting the translator config and the factory for it, (as required by the error template - I suppose i could have removed even that, as not required) it started working.
Hey presto!
Upvotes: 0
Reputation: 2251
If you add return
it should work:
return this->redirect()->toRoute('postList');
Upvotes: 6