rust-lang / rust-lang/mdBook

Redirects should have loop detection

Open
#2,901 1 comment 0 reactions 1 assignee View on GitHub

@Aumnertic is already working on this.

Since Aug 27, 2026.

A-redirect C-bug
Dominant language
Rust
Stars
22.2k
Forks
1.9k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.