Skip to content

Commit 2575621

Browse files
Document partial wildcard redirects (#2433)
* Update create/redirects.mdx Co-Authored-By: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> * document partial wildcard matching --------- Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com> Co-authored-by: Ethan Palm <56270045+ethanpalm@users.noreply.github.com>
1 parent 8c3a835 commit 2575621

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

create/redirects.mdx

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Set up 301 redirects by adding the `redirects` field to your `docs.json` file.
2121

2222
This permanently redirects `/source/path` to `/destination/path` so that you don't lose any previous SEO for the original page.
2323

24+
### Wildcard redirects
25+
2426
To match a wildcard path, use `*` after a parameter. In this example, `/beta/:slug*` matches `/beta/introduction` and redirects it to `/v2/introduction`.
2527

2628
```json
@@ -32,22 +34,51 @@ To match a wildcard path, use `*` after a parameter. In this example, `/beta/:sl
3234
]
3335
```
3436

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": [
3871
{
3972
"source": "/docs/:slug*",
4073
"destination": "/:slug*"
4174
}
42-
```
43-
</Warning>
75+
]
76+
```
4477

45-
## Broken links
78+
## Check for broken links
4679

47-
Catch broken links with our CLI. [Install the CLI](/installation) and run the command:
80+
Find broken links with the [CLI](/installation).
4881

4982
```bash
5083
mint broken-links
5184
```
52-
53-
The CLI identifies any relative links in your docs that don't exist.

0 commit comments

Comments
 (0)