Answer

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)));
  • 56
Reply Report
    • If you have a route defined, you can actually use $this->redirectToRoute('routename', ['param1' => 'value', ['param2' => 'value'])
      • 1
    • If you have a route defined, you can replace 'default' by its name, and change the second parameter with the routes's parameters, if needed.

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)

  • 5
Reply Report
$this->redirect('input/new/year/' . $year . '/month/' . $month);
  • -3
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions