February 22, 2018 Javier Eguiluz

In web applications is common to use the 301 HTTP status code to make permanent redirections and the 302 code to make temporary redirections. However, a problem with these redirection types is that a POST request is transformed into a GET request when doing the redirection for legacy reasons (redirecting a POST request didn't work well in old browsers).

In order to solve these issues, the HTTP standard introduced two new status codes:

307 (Temporary Redirect): defined in RFC 7231 and similar to 302 (Found), except that it does not allow changing the request method from POST to GET .

(Temporary Redirect): defined in RFC 7231 and similar to (Found), except that it does not allow changing the request method from to . 308 (Permanent Redirect): defined in RFC 7538 and similar to 301 (Moved Permanently), except that it does not allow changing the request method from POST to GET .

In Symfony 4.1 we added support for these new redirection types by adding a new keepRequestMethod argument to the redirectAction() and urlRedirectAction() methods of the RedirectController . You can also use it as the keepRequestMethod option in the route definitions: