Simple redirect in Symfony2 by changing a query string parameter, NOT route related

php, symfony

Solution

I hope I understand what you intend to do... In your controller (?) use

$this->generateUrl(
    $request->attributes->get('_route'),
    array_merge(
        $request->query->all(),
        array('param' => 'val') // change the param
    )
);

to generate the url.

Problem

This should be simple, and I've been searching all over Google, but I keep coming up with 'route' related advice. I just want to perform a redirect to the same page and modify one of the query string parameters (either to clear one or set one). I can't see how to do this anywhere. An option could be to completely generate the URL manually and use this I guess, but that doesn't seem a very good method: ``` $this->router->generate("http://domain.com?a=1") ```

Original source