Redirects
Almost nothing here answers with a document. The addresses below
answer with a Location and send the request somewhere
else, and where they send it is the point: back to themselves, back
to the address before them, or on to another address that does the
same thing again.
Every client that follows redirects stops after a number of them.
That number is the whole subject of this site, so the fixtures are
cut to sit either side of the ones this project uses: 5,
which is what the plain HTTP client allows before it gives up,
10, which the availability check counts to, and
20, which is where Chrome answers
ERR_TOO_MANY_REDIRECTS and the render fails.
None of this is a file. A redirect is something a server does, and
here it is index.php that does it: none of the
addresses below has a document behind it, so the server hands each
one to that file, which answers with a Location.
Nothing about this site has to be written into a server
configuration.
Loops with no way out
- Its own destination — one address, 302, pointing at itself
- The same, permanently — 308 to itself, which a browser is entitled to remember and repeat without asking again
- Ping — 302 to pong, which is a 302 back to ping
- A ring of eight — eight addresses in a cycle, so a hop count runs out four hops before the repeat would have shown up
- A chain that grows — every hop adds a segment to the address, so no URL is ever seen twice and only a counter ever stops it
- The www loop — the misconfiguration this error is famous for:
wwwredirects to the bare host, which redirects towww
Chains that do end
- Three hops — inside every budget, so this one is the control: it should be reported as the page it lands on
- Five hops, five statuses — 301, 302, 303, 307 and 308, one each, ending exactly on the plain client's limit of five
- Twelve hops — past 5 and past 10, but short of Chrome's 20: a render finds the page and everything fetched without a browser gives up
Chains that end somewhere unhelpful
- To a 404 — one hop, and what it points at is not there
- To a blocked page — one hop into
/private/, which robots.txt disallows - To a loop — an ordinary looking link whose one hop lands in the ping-pong pair
- To a mailto — a redirect to a scheme no crawler speaks
- A 302 with nothing to follow — the status says the page moved and no header says where
- An absolute loop — the same self-redirect written as a full URL rather than a relative one
- A redirect with a body — a 302 carrying a whole page, links and all, that nobody following it will ever read
Redirects written in the document
Neither of these is an HTTP redirect. The status is 200 and the body is a real page, so anything that only reads responses records them as ordinary documents and only a renderer ever goes anywhere.
- A meta refresh loop — two pages refreshing to each other with no delay, and only the first is linked: the second is an address nothing but a render ever arrives at
- A meta refresh to itself — the same page, over and over
- A script loop —
location.replace()between two pages, both of them linked, so a parser finds the pair and never learns what they do - A refresh into an HTTP loop — a 200 page whose meta refresh lands in the ping-pong pair