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.
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. Each subcommand uses the linked project unless you pass --project with a project name or ID.
List all redirects for the current project. These redirects apply to all deployments and environments.
vercel redirects list [options]Options:
--next <CURSOR>: Show the next page, using the cursor that the CLI prints with the previous page--limit <NUMBER>: Number of redirects per page (default: 50)-q, --query <TEXT>: Search for redirects by source or destination--staging: List redirects from the staging version--redirects-version <VERSION_ID>: List redirects from a specific version ID
Examples:
# List all redirects
vercel redirects list
# Search for redirects
vercel redirects list --query "/old-path"
# Show the next page, using the cursor from the previous page
vercel redirects list --next 2
# List redirects with custom page size
vercel redirects list --limit 25
# List redirects from staging version
vercel redirects list --staging
# List redirects from a specific version
vercel redirects list --redirects-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 --yesImport redirects from a CSV or JSON file.
vercel redirects import file [options]Options:
--force: Replace all existing redirects-y, --yes: Skip confirmation prompt
Examples:
# Import redirects from CSV file
vercel redirects import redirects.csv
# Import redirects from JSON file
vercel redirects import redirects.json
# Import and replace all existing redirects
vercel redirects import redirects.csv --force
# Import without confirmation
vercel redirects import redirects.csv --yesCSV Format:
source,destination,statusCode,caseSensitive,preserveQueryParams
/old-path,/new-path,301,false,true
/legacy/page,/modern/page,308,false,false
/old-blog,/blog,302,false,falseJSON Format:
[
{
"source": "/old-path",
"destination": "/new-path",
"statusCode": 301,
"caseSensitive": false,
"preserveQueryParams": true
},
{
"source": "/legacy/page",
"destination": "/modern/page",
"statusCode": 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?