From 6f036ee505d1a33c328558a8a50c6a5a441eaecb Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 7 Feb 2026 15:27:05 +0000 Subject: [PATCH] docs: document inline comments in _redirects files Co-Authored-By: pbacondarwin@cloudflare.com --- src/content/partials/workers/redirects.mdx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/content/partials/workers/redirects.mdx b/src/content/partials/workers/redirects.mdx index 77953f416e9f681..10a5215b368eefc 100644 --- a/src/content/partials/workers/redirects.mdx +++ b/src/content/partials/workers/redirects.mdx @@ -45,8 +45,19 @@ Only one redirect can be defined per line and must follow this format, otherwise - Optional parameter +### Comments + Lines starting with a `#` will be treated as comments. +You can also add inline comments to redirect rules. Any `#` token that appears after the `source` and `destination` (and optional `code`) will be treated as the start of a comment and ignored. URL fragments (for example, `/page#section`) are not affected because they do not have a space before the `#`. + +```txt +# Full-line comment explaining the next group of redirects +/old-page /new-page 301 # Moved during site redesign +/blog/* /articles/:splat # Blog URL migration +/page /page2#section 301 # URL fragment is preserved +``` + ### Per file A `_redirects` file is limited to 2,000 static redirects and 100 dynamic redirects, for a combined total of 2,100 redirects. Each redirect declaration has a 1,000-character limit. @@ -67,7 +78,7 @@ A complete example with multiple redirects may look like the following: /trailing /trailing/ 301 /notrailing/ /nottrailing 301 /page/ /page2/#fragment 301 -/blog/* https://blog.my.domain/:splat +/blog/* https://blog.my.domain/:splat # Blog migration /products/:code/:name /products?code=:code&name=:name ```