How can I redirect to another action passing 2 or more parameters?
This code:
$this->redirect('input/new?year=' . $year . '&month=' . $month);
Results in URL:
http://.../input?year=2009&month=9
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)));
$this->redirectToRoute('routename', ['param1' => 'value', ['param2' => 'value'])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
);
Strange thing. Does
$this->redirect('@default?module=input&action=new&year=' . $year . '&month=' . $month);
work for you?
$this->redirect('input/new/year/' . $year . '/month/' . $month);