Redirects
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.
There are two ways to add redirects in the Sentry docs:
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.
Set up all simple one-to-one redirects in src/middleware.ts
.
To add a new redirect in src/middleware.ts
, add a new object to REDIRECTS
with the following properties:
from
: The incoming request path.to
: The new destination path you want to route to.
The example below redirects https://docs.sentry.io/performance/
to https://docs.sentry.io/product/performance/
:
middleware.ts
const REDIRECTS: {from: PathWithTrailingSlash; to: string}[] = [
{
from: '/performance/',
to: '/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
.
To add a new redirect in vercel.json
, add a new object in redirects
with the following properties:
source
: The incoming request path pattern.destination
: The new destination path you want to route to.
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/
.
vercel.json
"redirects": [
{
"source": "/cli/(.*)",
"destination": "/product/cli/$1"
},
]
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").