vercel redirects
The vercel redirects command lets you manage redirects for a project. Redirects managed at the project level apply to all deployments and environments and take effect immediately after being created and promoted to production.
Redirects can also be defined and managed in source control using
vercel.json. Project-level redirects are updated without a need for a new
deployment.
vercel redirects listUsing the vercel redirects command to list all
redirects for the current project.
The vercel redirects command includes several subcommands for managing redirects:
List all redirects for the current project. These redirects apply to all deployments and environments.
vercel redirects list [options]Options:
--page <NUMBER>: Page number to display--per-page <NUMBER>: Number of redirects per page (default: 50)-s, --search <QUERY>: Search for redirects by source or destination--staged: List redirects from the staging version--version <VERSION_ID>: List redirects from a specific version ID
Examples:
# List all redirects
vercel redirects list
# Search for redirects
vercel redirects list --search "/old-path"
# List redirects on page 2
vercel redirects list --page 2
# List redirects with custom page size
vercel redirects list --per-page 25
# List redirects from staging version
vercel redirects list --staged
# List redirects from a specific version
vercel redirects list --version ver_abc123List all versions of redirects for the current project.
vercel redirects list-versionsAdd a new redirect to your project.
vercel redirects add [source] [destination] [options]Options:
--case-sensitive: Make the redirect case sensitive--name <NAME>: Version name for this redirect (max 256 characters)--preserve-query-params: Preserve query parameters when redirecting--status <CODE>: HTTP status code (301, 302, 307, or 308)-y, --yes: Skip prompts and use default values
Examples:
# Add a new redirect interactively
vercel redirects add
# Add a new redirect with arguments
vercel redirects add /old-path /new-path
# Add a redirect with all options
vercel redirects add /old-path /new-path --status 301 --case-sensitive --preserve-query-params --name "My redirect"
# Add a redirect non-interactively
vercel redirects add /old-path /new-path --yesUpload redirects from a CSV or JSON file.
vercel redirects upload file [options]Options:
--overwrite: Replace all existing redirects-y, --yes: Skip confirmation prompt
Examples:
# Upload redirects from CSV file
vercel redirects upload redirects.csv
# Upload redirects from JSON file
vercel redirects upload redirects.json
# Upload and overwrite existing redirects
vercel redirects upload redirects.csv --overwrite
# Upload without confirmation
vercel redirects upload redirects.csv --yesCSV Format:
source,destination,status,caseSensitive,preserveQueryParams
/old-path,/new-path,301,false,true
/legacy/*,/modern/:splat,308,false,false
/old-blog,/blog,302,false,falseJSON Format:
[
{
"source": "/old-path",
"destination": "/new-path",
"status": 301,
"caseSensitive": false,
"preserveQueryParams": true
},
{
"source": "/legacy/*",
"destination": "/modern/:splat",
"status": 308,
"caseSensitive": false,
"preserveQueryParams": false
}
]Remove a redirect from your project.
vercel redirects remove source [options]Options:
-y, --yes: Skip the confirmation prompt when removing a redirect
Example:
# Remove a redirect
vercel redirects remove /old-pathPromote a staged redirects version to production.
vercel redirects promote version-id [options]Options:
-y, --yes: Skip the confirmation prompt when promoting
Example:
# Promote a redirect version
vercel redirects promote <version-id>Restore a previous redirects version.
vercel redirects restore version-id [options]Options:
-y, --yes: Skip the confirmation prompt when restoring
Example:
# Restore a redirects version
vercel redirects restore <version-id>The following global options can be passed when using the vercel redirects command:
For more information on global options and their usage, refer to the options section.
Was this helpful?