Skip to content

Create a rewrite rule

POST
/api/zones/{zoneId}/rewrite-rules

Adds a new URL rewrite rule to the zone. The rule is attached to the zone from the URI. If "order" is omitted, the rule is appended (highest existing order + 1); if an explicit "order" is provided, existing rules at or after that position are shifted down to keep ordering contiguous. The name and the operator+source-pattern combination must be unique within the zone, and the zone's rule limit must not be exceeded. When the operator is a regex variant, the source pattern must be a safe regular expression and the target may only reference capture groups that exist in the pattern.

Authorizations

ApiToken

Long-lived API token created via POST /api/api-tokens (returned once in plaintext).

Type
API Key (header: X-API-TOKEN)
or
JWT

JWT access token obtained via POST /api/auth/login. Send as: Authorization: Bearer .

Type
HTTP (bearer)

Parameters

Path Parameters

zoneId*

Zone identifier

Type
string
Required

Request Body

JSON
{
  
"name": "Redirect old blog paths",
  
"description": "Rewrites legacy /blog/* URLs to the new /articles/* structure.",
  
"operator": "regex",
  
"sourcePattern": "^/blog/(.*)$",
  
"target": "/articles/$1",
  
"order": 0,
  
"enabled": true
}

Responses

rewrite-rule resource created

JSON
{
  
"@context": "string",
  
"@id": "string",
  
"@type": "string",
  
"id": "string",
  
"zone": "https://example.com/",
  
"name": "Redirect old blog paths",
  
"description": "Rewrites legacy /blog/* URLs to the new /articles/* structure.",
  
"operator": "regex",
  
"sourcePattern": "^/blog/(.*)$",
  
"target": "/articles/$1",
  
"order": 0,
  
"enabled": true,
  
"createdAt": "string",
  
"updatedAt": "string"
}

Playground

Authorization
Variables
Key
Value
Body

Samples

Powered by VitePress OpenAPI