You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/snippets/redirects.mdx
+24-18Lines changed: 24 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@ The `redirects` object allows you to redirect traffic from one path to another.
2
2
3
3
If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include the subpath in both the source and destination paths.
4
4
5
-
6
5
<CodeBlocktitle="docs.yml">
6
+
7
7
```yml
8
8
redirects:
9
9
# Exact path redirects
@@ -35,11 +35,24 @@ If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include t
35
35
Parameters suffixed with an asterisk (`*`) match zero or more path segments, capturing everything that follows in the URL. Use this when redirecting entire folder structures while preserving nested paths.
The path you want to route to. Can be an internal path (`/new-path`) or an external URL (`https://example.com`). External URLs must include the full address, including `https`.
`true`or `false` - default is `true`. If `true`, will use the 308 status code which instructs clients/search engines to cache the redirect forever. If `false`, will use the 307 status code which is temporary and is not cached.
48
+
</ParamField>
49
+
38
50
### Advanced patterns
39
51
40
-
Fern uses [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp) for pattern matching. Named capture groups can be defined with regex patterns and reused in destination URLs:
52
+
You can define named capture groups with regex patterns and reuse them in destination URLs:
41
53
42
54
<CodeBlock title="docs.yml">
55
+
43
56
```yml
44
57
redirects:
45
58
# Match 4-digit years
@@ -56,24 +69,17 @@ redirects:
56
69
```
57
70
</CodeBlock>
58
71
59
-
**Pattern syntax:**
60
-
- `:name`- Captures a single path segment
61
-
- `:name*`- Captures zero or more segments
62
-
- `:name(\\d+)`- Captures digits only
63
-
- `:name(\\d{4})`- Captures exactly 4 digits
64
-
- `{0}`- Literal character delimiter between parameters
The path you want to route to. Can be an internal path (`/new-path`) or an external URL (`https://example.com`). External URLs must include the full address, including `https`.
`true`or `false` - default is `true`. If `true`, will use the 308 status code which instructs clients/search engines to cache the redirect forever. If `false`, will use the 307 status code which is temporary and is not cached.
0 commit comments