Subscribe to PHP Freaks RSS

307 Temporary Redirect

syndicated from planet-php.net on October 30, 2018

307 Temporary Redirect is similar to 302 Found in that it tells a client to temporarily redirect to a different location to access the requested resource.



The difference from 302 is that with a 307, the client must follow the location and issue the exact same request again. So if it did a POST request on the orginal resource, it should follow the redirect and do the POST request again.



This is unlike a 302 where a client may change the request to a GET. In practice all clients change their HTTP request to a GET.



I tested Firefox, Curl and Chrome. For each of them I tested doing a POST request. Each of them redirected and did an identical request on the target url. In the case of Firefox and Chrome, I tested both a html form and the Fetch API.



I couldn’t test Edge and Safari, but assuming their behavior is similar, I think it problaby makes more sense to always use 307 Temporary Redirect or 303 See Other in cases where most people use 302 Found today.



Stop using 302, and start using 307 and 303!



Example



HTTP/1.1 307 Temporary Redirect
Server: gws
Location: https://evertpot.com/http/307-temporary-redirect


References