Skip to main content
The Redirects API allows you to configure URL redirects and path rewrites at the environment level.

Get Redirects

endpoint
Retrieve all redirect rules for an environment.

Response

array
Array of redirect objects

Set Redirects

endpoint
Update redirect rules for an environment.
This endpoint replaces all existing redirects. Include all redirect rules you want to keep.

Request Body

array
required
Array of redirect objects to set

Response

array
The updated array of redirect objects

Redirect Types

Path Rewrite (Status 200)

Serve content from a different path without changing the URL:
This is commonly used for single-page applications to handle client-side routing.

Permanent Redirect (Status 301)

Redirect permanently to a new URL:
Use for moved content that won’t be returning to the old URL.

Temporary Redirect (Status 302)

Redirect temporarily to a different URL:
Use when content is temporarily moved but will return to the original URL.

Advanced Patterns

Wildcard Redirects

Use * to match any path segment:
This redirects /blog/my-post to /articles/my-post.

Regex Patterns

Use regex capture groups with $1, $2, etc.:

Host-Specific Redirects

Apply redirects only to specific domains:

Domain Redirects

Redirect from one domain to another:

Excluding Assets

By default, wildcard redirects exclude asset files (files with extensions). To include assets:
Setting assets: true will apply the redirect to all files including CSS, JavaScript, and images. Use with caution.

Common Use Cases

Single Page Application

WWW to Non-WWW

Multiple Redirects with Priorities

Redirects are processed in order. More specific rules should be placed before general wildcard rules.