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: create/redirects.mdx
+40-9Lines changed: 40 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ Set up 301 redirects by adding the `redirects` field to your `docs.json` file.
21
21
22
22
This permanently redirects `/source/path` to `/destination/path` so that you don't lose any previous SEO for the original page.
23
23
24
+
### Wildcard redirects
25
+
24
26
To match a wildcard path, use `*` after a parameter. In this example, `/beta/:slug*` matches `/beta/introduction` and redirects it to `/v2/introduction`.
25
27
26
28
```json
@@ -32,22 +34,51 @@ To match a wildcard path, use `*` after a parameter. In this example, `/beta/:sl
32
34
]
33
35
```
34
36
35
-
<Warning>
36
-
The destination slug cannot match to the source slug. For example, if your docs are hosted at `/docs`, avoid:
37
-
```json
37
+
### Partial wildcard redirects
38
+
39
+
Use partial wildcards to match URL segments that start with a specific prefix.
40
+
41
+
```json
42
+
"redirects": [
43
+
{
44
+
"source": "/articles/concepts-*",
45
+
"destination": "/collections/overview"
46
+
}
47
+
]
48
+
```
49
+
50
+
This matches any URLs with the `/articles/concepts-` path, such as `/articles/concepts-getting-started` and `/articles/concepts-overview`, and redirects them all to `/collections/overview`.
51
+
52
+
You can also substitute the captured wildcard value in the destination.
53
+
54
+
```json
55
+
"redirects": [
56
+
{
57
+
"source": "/old/article-*",
58
+
"destination": "/new/article-*"
59
+
}
60
+
]
61
+
```
62
+
63
+
This redirects `/old/article-123` to `/new/article-123`, preserving the captured value after the prefix.
64
+
65
+
### Avoid infinite redirects
66
+
67
+
To avoid infinite loops, the destination slug cannot match the source slug. For example, if your docs are hosted at `/docs`, avoid:
68
+
69
+
```json
70
+
"redirects": [
38
71
{
39
72
"source": "/docs/:slug*",
40
73
"destination": "/:slug*"
41
74
}
42
-
```
43
-
</Warning>
75
+
]
76
+
```
44
77
45
-
## Broken links
78
+
## Check for broken links
46
79
47
-
Catch broken links with our CLI. [Install the CLI](/installation) and run the command:
80
+
Find broken links with the [CLI](/installation).
48
81
49
82
```bash
50
83
mint broken-links
51
84
```
52
-
53
-
The CLI identifies any relative links in your docs that don't exist.
0 commit comments