From 1a4bfe5c3554b48b8a1b38244d03861b5abd1cc1 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 13:26:16 +0000 Subject: [PATCH 1/2] docs: document mid-segment redirect matching with regex-constrained params --- fern/products/docs/pages/seo/redirects.mdx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fern/products/docs/pages/seo/redirects.mdx b/fern/products/docs/pages/seo/redirects.mdx index 96dbec8083..314fc4c768 100644 --- a/fern/products/docs/pages/seo/redirects.mdx +++ b/fern/products/docs/pages/seo/redirects.mdx @@ -54,6 +54,20 @@ Redirects are evaluated top-to-bottom and the first match wins: A broader pattern listed before a more specific one prevents the specific rule from ever matching. +### Match part of a path segment + +`:slug` and `:slug*` only match whole path segments, so they must follow a `/`. To match mid-segment, give the parameter an explicit pattern in parentheses: + + + ```yml + redirects: + - source: "/plants/legacy-:slug(.*)" # Matches /plants/legacy-monstera + destination: "/plants/:slug(.*)" + ``` + + +A `(.*)` pattern also captures `/` characters, so it matches across segments. Repeat the same pattern on the parameter in `destination`. + ## Properties From c8fb69387f997ef2d780785d01c3515b77fb03a7 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 13:27:59 +0000 Subject: [PATCH 2/2] docs: clarify that plain params can start mid-segment --- fern/products/docs/pages/seo/redirects.mdx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fern/products/docs/pages/seo/redirects.mdx b/fern/products/docs/pages/seo/redirects.mdx index 314fc4c768..771b9bb585 100644 --- a/fern/products/docs/pages/seo/redirects.mdx +++ b/fern/products/docs/pages/seo/redirects.mdx @@ -56,17 +56,25 @@ A broader pattern listed before a more specific one prevents the specific rule f ### Match part of a path segment -`:slug` and `:slug*` only match whole path segments, so they must follow a `/`. To match mid-segment, give the parameter an explicit pattern in parentheses: +A parameter can start mid-segment, but `:slug` stops at the next `/`: ```yml redirects: - - source: "/plants/legacy-:slug(.*)" # Matches /plants/legacy-monstera - destination: "/plants/:slug(.*)" + - source: "/plants/legacy-:slug" # Matches /plants/legacy-monstera, not /plants/legacy-monstera/care + destination: "/plants/:slug" ``` -A `(.*)` pattern also captures `/` characters, so it matches across segments. Repeat the same pattern on the parameter in `destination`. +`:slug*` requires a leading `/` and doesn't work mid-segment. To capture the rest of the path from mid-segment, give the parameter an explicit pattern in parentheses, and repeat that pattern in `destination`: + + + ```yml + redirects: + - source: "/plants/legacy-:slug(.*)" # Matches /plants/legacy-monstera/care + destination: "/plants/:slug(.*)" + ``` + ## Properties