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: docs/contributing/pages/redirects.mdx
+46-20Lines changed: 46 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,31 +3,57 @@ title: Redirects
3
3
noindex: true
4
4
---
5
5
6
-
7
6
Redirects allow you to automatically redirect an incoming request path to a new destination path. When you move or rename a file, you should make sure to set up a redirect from the old path to the new path, so that the old URL still takes users to the right place.
8
7
9
8
## Add a New Redirect
10
9
11
-
Redirects are configured in [`next.config.js`](https://github.com/getsentry/sentry-docs/blob/master/next.config.js) and are checked before the filesystem (including pages and `/public` files ). The `redirects` function returns an array holding redirect objects.
10
+
There are two ways to add redirects in the Sentry docs:
11
+
12
+
-[Add a New Redirect in `middleware.ts` (Recommended)](#add-a-new-redirect-in-middlewarets-recommended)
13
+
-[Add a New Redirect in `vercel.json`](#add-a-new-redirect-in-verceljson)
14
+
15
+
Because Sentry has a limited number of Vercel redirects, you should configure your redirects in `middleware.ts` whenever possible. You should only use `vercel.json` if you need to use regular expressions in your redirects.
16
+
17
+
### Add a New Redirect in `middleware.ts` (Recommended)
18
+
19
+
Set up all simple one-to-one redirects in `src/middleware.ts`.
20
+
21
+
To add a new redirect in [`src/middleware.ts`](https://github.com/getsentry/sentry-docs/blob/master/src/middleware.ts), add a new object to `REDIRECTS` with the following properties:
22
+
23
+
-`from`: The incoming request path.
24
+
-`to`: The new destination path you want to route to.
25
+
26
+
#### Example Redirect in `middleware.ts`
12
27
13
-
To add a new redirect, add a new object in the redirects array with the following properties:
28
+
The example below redirects `https://docs.sentry.io/performance/` to `https://docs.sentry.io/product/performance/`:
Sentry has a limited number of Vercel redirects, so you should only configure redirects in `vercel.json` if your redirects need to use regular expressions. Otherwise, use [`middleware.ts`](#add-a-new-redirect-in-middlewarets-recommended).
42
+
43
+
To add a new redirect in [`vercel.json`](https://github.com/getsentry/sentry-docs/blob/master/vercel.json#L34), add a new object in `redirects` with the following properties:
14
44
15
45
-`source`: The incoming request path pattern.
16
-
-`destination`: The new destination path you want to route to instead.
17
-
-`permanent`: Whether the redirect is permanent and should be cached forever (`true`) or is temporary (`false`).
18
-
19
-
### Example Redirect
20
-
21
-
The example below adds a redirect for the alerts page after its parent folder was renamed from `alerts-notifications` to `alerts`.
22
-
23
-
```javascript {filename:next.config.js}
24
-
redirects() {
25
-
return [
26
-
{
27
-
source:'/product/alerts-notifications/',
28
-
destination:'/product/alerts/',
29
-
permanent:true,
30
-
},
31
-
]
32
-
}
46
+
-`destination`: The new destination path you want to route to.
47
+
48
+
#### Example Redirect in `vercel.json`
49
+
50
+
The example below redirects URLs like `https://docs.sentry.io/cli/(.*)` to `https://docs.sentry.io/product/cli/$1` with a matching regex pattern. For example, `https://docs.sentry.io/cli/installation/` would be redirected to `https://docs.sentry.io/product/cli/installation/`.
0 commit comments