Skip to content

Commit e2c55a5

Browse files
authored
(docs) Add info about external redirects, clarify comments (#976)
1 parent 6da4356 commit e2c55a5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

fern/snippets/redirects.mdx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The `redirects` object allows you to redirect traffic from one path to another. You can redirect exact paths or use dynamic patterns with [`regex`](https://www.npmjs.com/package/path-to-regexp) parameters like `:slug`.
1+
The `redirects` object allows you to redirect traffic from one path to another. You can redirect exact paths or use dynamic patterns with [`regex`](https://www.npmjs.com/package/path-to-regexp) parameters like `:slug` to handle bulk redirects. You can redirect to internal paths within your site or external URLs.
22

33
If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include the subpath in both the source and destination paths.
44

@@ -12,27 +12,29 @@ If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include t
1212
- source: "/old-folder/path"
1313
destination: "/new-folder/path"
1414
permanent: true
15+
- source: "/old-folder/path"
16+
destination: "https://www.example.com/fern" # External destination
1517

16-
# Regex-based redirects
17-
- source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc.
18-
destination: "/new-folder/:slug"
19-
- source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc.
20-
destination: "/new-folder/:slug*"
18+
# Regex-based redirects
19+
- source: "/old-folder/:slug" # Matches single segments: /old-folder/foo
20+
destination: "/new-folder/:slug"
21+
- source: "/old-folder/:slug*" # Matches multiple segments: /old-folder/foo/bar/baz
22+
destination: "/new-folder/:slug*"
2123
```
2224
</CodeBlock>
2325
2426
<Info>
25-
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.
26-
</Info>
27+
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.
28+
</Info>
2729

2830
<ParamField path="source" type="string" required={true}>
29-
The path that you want to redirect from.
31+
The internal path that you want to redirect from.
3032
</ParamField>
3133

3234
<ParamField path="destination" type="string" required={true}>
33-
The path that you want to redirect to.
35+
The path or URL that you want to redirect to. Can be an internal path (`/new-path`) or an external URL (`https://example.com`). External URLs must include the full address, including `https`.
3436
</ParamField>
3537

3638
<ParamField path="permanent" type="boolean" required={false}>
37-
Toggle between **permanent** and **temporary** redirect (default `false`). When true, the status code is 308. When false, the status code is 307.
39+
Toggle between **permanent** and **temporary** redirects (default `false`). When true, the status code is 308. When false, the status code is 307.
3840
</ParamField>

0 commit comments

Comments
 (0)