-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathvercel-redirects.mdc
More file actions
81 lines (61 loc) · 2.48 KB
/
Copy pathvercel-redirects.mdc
File metadata and controls
81 lines (61 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
description: Vercel redirect rules for vercel.json — trailing-slash source patterns and what not to duplicate.
globs: vercel.json
alwaysApply: false
---
# Vercel redirects (`vercel.json`)
Every deleted, renamed, or moved page needs a redirect in `vercel.json`. Docusaurus sets
`onBrokenLinks: 'throw'`, so fix internal links in the repo too.
## Platform settings
`vercel.json` sets `"trailingSlash": true` and `"cleanUrls": false`. Docusaurus also uses
`trailingSlash: true`. Redirect rules must match how Vercel actually routes requests.
## Trailing-slash behavior
With `trailingSlash: true`, Vercel **always normalizes** a no-slash URL to its slash form
**before** custom redirects run:
```text
/foo/bar → 308 /foo/bar/ → (custom redirect, if source matches)
```
Therefore:
- **`source` must end with `/`** for normal documentation paths.
- **Do not add a duplicate** no-slash `source` for the same redirect. Only `/foo/bar/` is
needed; `/foo/bar` is redundant.
- **`destination` must end with `/`** for normal documentation paths (unless the target is a
static file or includes a `#` fragment).
### File-extension paths
Paths whose final segment contains a dot (for example, `.html`, `.txt`) are treated as files.
Vercel does **not** append a trailing slash. Keep the **no-slash** `source` for those paths only.
## Examples
```json
// ✅ GOOD — one rule; works for both /old/path and /old/path/
{
"source": "/agent-wallet/get-started/quickstart/",
"destination": "/agent-wallet/quickstart/",
"permanent": true
}
// ❌ BAD — no-slash source never matches after Vercel normalization
{
"source": "/agent-wallet/get-started/quickstart",
"destination": "/agent-wallet/quickstart"
}
// ❌ BAD — duplicate rules for the same redirect
{
"source": "/agent-wallet/get-started/quickstart/",
"destination": "/agent-wallet/quickstart/"
},
{
"source": "/agent-wallet/get-started/quickstart",
"destination": "/agent-wallet/quickstart/"
}
// ✅ GOOD — file path; no trailing slash on source
{
"source": "/guide/ethereum-provider.html",
"destination": "/metamask-connect/evm/reference/provider-api/"
}
```
## Verify before merging
Test the **slash** `source` (and optionally the no-slash entry URL, which should chain through):
```bash
curl -sI -L "https://docs.metamask.io/old/path/" | grep -E "^HTTP|^location"
```
Expect a `308` chain ending in `200` at the destination. A `404` after a trailing-slash
normalization hop usually means the `source` is missing its final `/`.