Redirect Back to parent page


I reuse (include) a twig view (statuses.twig) on two different pages; timeline.twig (url is “localhost/coolsite/public/timeline/”) and profile.twig (“localhost/coolsite/public/profile/josh”).The statuses.twig view has a form which allows the user to reply to a status. the action of the form points to lets say “localhost/coolsite/public/status/4/reply/” After the user click the reply button, I will like it to redirect to the same page (either the timeline or the profile page depending on which page it is currently on). However, I’m experiencing that it is redirecting to the url of the form and not to the url of the page that the form is within.

I use the following:

return $response->withRedirect((string)$request->getUri());

but it only returns the url of the form and not the parent page the form is in.


is there not one who could help?

You can redirect to a string like: “location:javascript://history.go(-1)” or whatever nr you want to go back to.