#2901·mdBook

Redirects should have loop detection

Author: ehussCreated Oct 25, 2025Updated Aug 27, 2026
LabelsC-bugA-redirect

Problem

If a redirect chain ends in a loop, the browser will reload the pages indefinitely.

Steps

Set up a redirect loop, such as the following:

[output.html.redirect]
"/chapter_1.html#a" = "chapter_2.html#b"
"/chapter_2.html#b" = "chapter_1.html#a"

with a SUMMARY.md:

# Summary

- [Chapter 1](./chapter_1.md)
- [Chapter 2](./chapter_2.md)

Navigate to chapter_1.html#a

Possible Solution(s)

I'm not sure exactly what should be done. One thing to consider is that loops can happen in between books. Some ideas:

  • During book building, detect a loop and report an error.
  • When redirecting, use some mechanism to track the number of redirects. I don't know what this would look like, but url query parameters, cookies, or localstorage are some potential options. It looks like browsers allow roughly 20 redirects (when using http redirects).

Notes

No response

Version

mdbook v0.5.0-alpha.1