Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions fern/products/docs/pages/seo/redirects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 `/`:

<CodeBlock title="docs.yml">
```yml
redirects:
- source: "/plants/legacy-:slug" # Matches /plants/legacy-monstera, not /plants/legacy-monstera/care
destination: "/plants/:slug"
```
</CodeBlock>

`: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`:

<CodeBlock title="docs.yml">
```yml
redirects:
- source: "/plants/legacy-:slug(.*)" # Matches /plants/legacy-monstera/care
destination: "/plants/:slug(.*)"
```
</CodeBlock>

## Properties

<Markdown src="/products/docs/snippets/redirects.mdx" />
Expand Down
Loading