symfony redirect with 2 parameters symfony redirect with 2 parameters php php

symfony redirect with 2 parameters


Well, that's normal, "redirect" redirect to an absolute URL. You can do that:

$this->redirect($this->generateUrl('default', array('module' => 'input','action' => 'new', 'year' => $year, 'month' => $month)));


In the currently supported Symfony versions (2.7+) it's even easier (plus, you can optionally add also the status code at the end):

return $this->redirectToRoute(    'default',    array('year' => $year, 'month' => $month),    Response::HTTP_MOVED_PERMANENTLY // = 301);


You can also use redirect, specifying the route name and the parameter array:

$this->redirect('route_name', array('year' => $year, 'month' => $month));

(Tested on Symfony 1.4)