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
Improve redirects documentation with advanced regex patterns
- Add named capture group examples with regex patterns
- Document Path-to-RegExp syntax including {0} delimiter
- Include real-world examples (release notes, versioned APIs)
- Add pattern syntax reference table
- Based on user feedback about complex regex redirects
Co-Authored-By: [email protected] <[email protected]>
Copy file name to clipboardExpand all lines: fern/snippets/redirects.mdx
+37-3Lines changed: 37 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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` to handle bulk redirects. You can redirect to internal paths within your site or external URLs.
1
+
The `redirects` object allows you to redirect traffic from one path to another. You can redirect exact paths or use dynamic patterns with [Path-to-RegExp](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.
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
@@ -17,18 +17,52 @@ If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include t
17
17
destination: "/new-location"
18
18
permanent: false # Use 307 (temporary) instead of 308 (permanent)
19
19
20
-
#Regex-based redirects
20
+
#Pattern-based redirects
21
21
- source: "/old-folder/:slug"# Matches single segments: /old-folder/foo
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.
30
36
</Info>
31
37
38
+
### Advanced patterns
39
+
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:
0 commit comments