diff --git a/libavformat/http.c b/libavformat/http.c
index 1284c31de8443e6541b055c15b41f1dd3319de49..c1423cb54533cbc8d6c5c4a7e2b12ade1cf0c7e3 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -96,7 +96,7 @@ static int http_open_cnx(URLContext *h)
     s->hd = hd;
     if (http_connect(h, path, hoststr, auth, &location_changed) < 0)
         goto fail;
-    if (s->http_code == 303 && location_changed == 1) {
+    if ((s->http_code == 302 || s->http_code == 303) && location_changed == 1) {
         /* url moved, get next */
         url_close(hd);
         if (redirects++ >= MAX_REDIRECTS)