symfony redirect with 2 parameters

假装没事ソ 提交于 2019-11-28 05:19:21

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 currently supported Symfony versions (2.7+) it's even easier:

return $this->redirectToRoute('default', array('year' => $year, 'month' => $month));

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)

I think this is no normal symfony behavior. Have you defined some routing rules?

Have you also tried this:

$this->redirect('module/action?'.http_build_query($paramsArray));

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!