symfony2 redirectResponse

10,464

You cannot redirect and POST data directly on a redirection target.

If you're trying to send the data of a form post to another target, you can:

1) Change the action of the form to 'http://example.com' (here you're posting directly to that url, so you won't pass through your application (but the target site shouldn't have a CSRF protection for this to work)

2) In your controller you can create a querystring from your POST data, and append the querystring to the url (-> return new RedirectResponse( 'http://example.com?' + queryString);

Share:
10,464
Aleksei Kornushkin
Author by

Aleksei Kornushkin

Updated on June 04, 2022

Comments

  • Aleksei Kornushkin
    Aleksei Kornushkin almost 2 years

    I would like to create redirect response with POST parameters. For example controller returning some redirecting response that making redirect on http://example.com

    ...
    return new RedirectResponse('http://example.com');
    ...
    

    Is there any way to redirect to this URL (http://example.com) and send POST parameters to this URL using RedirectResponse class ?