diff --git a/fern/products/docs/pages/seo/redirects.mdx b/fern/products/docs/pages/seo/redirects.mdx index 96dbec8083..771b9bb585 100644 --- a/fern/products/docs/pages/seo/redirects.mdx +++ b/fern/products/docs/pages/seo/redirects.mdx @@ -54,6 +54,28 @@ 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 + +A parameter can start mid-segment, but `:slug` stops at the next `/`: + + + ```yml + redirects: + - source: "/plants/legacy-:slug" # Matches /plants/legacy-monstera, not /plants/legacy-monstera/care + destination: "/plants/:slug" + ``` + + +`: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