Create Redirect
Request Body
Regular expression pattern to match against incoming URLs. Supports standard regex syntax including capture groups.Examples:
^/old-path/(.*)- Match any path starting with/old-path/^/api/v1/(.*)- Match API v1 endpoints^/blog/(\d+)/(.*)- Match blog posts with numeric IDs
Replacement pattern for the redirect. Can reference capture groups from the regex using
$1, $2, etc.Examples:/new-path/$1- Preserve the captured path/api/v2/$1- Upgrade API versionhttps://example.com/$1- Redirect to external domain
Whether this is a permanent redirect (HTTP 301) or temporary (HTTP 302).
ID of the application this redirect rule applies to.
Response
Unique identifier for the created redirect rule.
The regex pattern.
The replacement pattern.
Whether this is a permanent redirect.
Associated application ID.
Unique key used for Traefik configuration.
ISO 8601 timestamp when the redirect was created.
Get Redirect
Query Parameters
ID of the redirect rule to retrieve.
Response
Returns the redirect rule object with all configuration details.Update Redirect
Request Body
ID of the redirect rule to update.
Updated regex pattern.
Updated replacement pattern.
Whether this is a permanent redirect.
Delete Redirect
Request Body
ID of the redirect rule to delete.
Redirect Examples
Force HTTPS
Redirect all HTTP traffic to HTTPS:Add Trailing Slash
Ensure all URLs end with a trailing slash:Remove www Prefix
Redirect www subdomain to apex domain:API Versioning
Redirect old API version to new version:Language Routing
Redirect based on language paths:Preserve Query Parameters
Query parameters are automatically preserved in redirects. For example,/old-path?foo=bar matching ^/old-path$ with replacement /new-path will redirect to /new-path?foo=bar.
Best Practices
Permanent vs Temporary Redirects
-
Use permanent redirects (301) when:
- You’ve permanently moved content
- You want search engines to update their indexes
- The old URL will never be used again
-
Use temporary redirects (302) when:
- The redirect is for maintenance or testing
- You might revert the change
- You want to preserve the original URL in search engines
Performance
- Keep regex patterns simple when possible
- Avoid complex lookaheads and lookbehinds
- Test redirect rules with realistic traffic patterns
- Monitor redirect chains (one redirect leading to another)