0
I have a route /curso/{slug}
which makes a 301 redirect to another route. That route /curso/{slug}
can receive some parameters per query (example: /curso/{slug}?query=1234
), but redirect to the other route using return $this->redirectToRoute('nova_rota', array('slug' => $slug)
, these query parameters are lost. How can I add the query parameters in this redirect.
Code block that redirects to the other route:
/**
* @Route("/{slug}", name="course_show")
*/
public function showAction(Request $request, $slug)
{
return $this->redirectToRoute('redirect_slug', array('slug' => $slug));
}
Already tried $this->redirectToRoute('redirect_slug', array('Slug' => $Slug, 'query' => 123))
– fajuchem
You can use $request->request->all() to take the parameters and merge an array with the second parameter passed in redirectToRoute, so it will dynamically take all the parameters and send in redirect tb.
– fajuchem
It worked, thanks. If you want, put as answer to the question, so I mark as solved...
– Matheus de Melo .F