Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum number of HTTP redirections allowed by all major browsers?

I am designing a web site, spread across many servers, and there are pages where I need up to chain up to 4 redirections in a row. I tried a few browsers (firefox, chrome, IE) and it seems to work fine.

Apparently, Firefox's default limit is 20 redirections in a row, Chrome's default seems to be 20, and IE8's limit seems to be 10 redirections.

What is the maximum number of HTTP redirections allowed by all major browsers? Is it 10?

Edit:

Why do I need 4 redirections? Basically, the user is in a hotspot, she tries to go to (say) google.com, there is a local captive portal that captures the request and redirects (#1) the user to a local server. The local server checks some things about the user, but if it does not have the data locally, it redirects (#2) the user to the central web site. If the user is already logged in to this central Web site, she gets redirected (#3) to another server (there are different portals depending on the user). Finally, the server checks the user's rights, and if she has the appropriate rights, there is a final (#4) redirection to the local access controller, in order to get access to the appropriate service. Believe me, I tried my best to remove redirections, but I cannot see where this can be optimized.

like image 343
MiniQuark Avatar asked Jun 05 '12 10:06

MiniQuark


2 Answers

4 redirections should work in all major browsers. However, consider reducing the number to give users a faster experience. Each redirection requires a round trip between the user and the server (and requires creating a new connection, if it's redirecting to a different server). In total, the latency will be significant, likely annoying your users.

like image 86
Mechanical snail Avatar answered Oct 19 '22 23:10

Mechanical snail


I also curious about this, but doesn't find info about what is the maximum number of redirection of each browser. So I try to test it by myself using this PHP code to each web browser that I have:

<?php
$count = $_GET["c"] ?? 0;
$next = $count+1;
header('Location:'.$_SERVER['PHP_SELF'].'?c='.$next);
exit;

The result is:

  • 20 = Firefox
  • 19 = Chrome, Opera, Brave, Opera Mini, Puffin, UC Browser, etc (maybe all blink based browser)
  • 16 = Safari

Question: What is the maximum number of HTTP redirections allowed by all major browsers? Is it 10?

Answer: Based on my test the maximum that allowed by all major browser is 16.


But I can not test IE/Edge because I don't have a windows OS. As Microsoft Edge use Blink engine, so I think the maximum 19 too. You can test above code using your own server or this link(mine). The last URL query number until show ERR_TOO_MANY_REDIRECTS error is the maximum redirection.

like image 34
Muhammad Dyas Yaskur Avatar answered Oct 19 '22 22:10

Muhammad Dyas Yaskur