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.

Redirect / Forward

How can i Redirect or Forward to previous controller dynamically ?


Send a request from : index/dashboard , to : request/setlanguage ;

So request/setlanguage will redirect back to where it has been requested.


One way would be using

$ref = $this->request->getHTTPReferer();

return $this->response->redirect($ref);

The disadvantage of this, would be that you need to ensure that the referer is your host.

Another way is to use dispatcher:

$controller = $this->dispatcher->getPreviousControllerName();
$action = $this->dispatcher->getPreviousActionName();

return $this->response->redirect("$controller/$action");