hosting

POST /v1/sites/{siteId}/redirects

Add a redirect to a site.

所有 hosting 端点

所有开发者文档

身份验证

请将 API 密钥作为 bearer 令牌发送。该密钥必须具有 sites.view 权限;缺少该权限的密钥将被拒绝并返回 403 状态码,而非 404。

此端点不需要组织 ID。您的密钥已用于识别其所属的组织,且响应范围也仅限于该组织。

免费试用

将尖括号中的内容替换为您自己的值,并将键占位符替换为您仪表板中的一个键。

curl -X POST https://api.zinndigital.com/v1/sites/{siteId}/redirects \
  -H "Authorization: Bearer zdk_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "domain": <string>, "path": <string>, "destination": <string> }'

已登录?您仪表板中的 API 控制台会自动填入您真实的组织 ID 和您自己的密钥,并针对实时 API 运行请求,以便您查看实际的响应。 在 API 控制台中打开此端点

详细信息

Adds one rule. ⛔ The vendor endpoint behind this is a whole-set write, so the engine reads the existing rules, appends, and sends the set back — last writer wins. Two people adding a redirect at the same moment is the one case where one of the two additions is lost, and there is no vendor primitive that would prevent it. destination is checked before anything is written to the customer's .htaccess: a protocol-relative //evil.example/ passes a naive "starts with a slash" test and redirects the site's visitors to somebody else's server, so it is refused 422 here. type is a closed set (301, 302) checked in this layer and in the driver, because the platform types it as a free string and an unreviewed token would be written straight into the file. 404 for a site with no managed hosting package. Requires sites.view and sites.panel_access.

参数

名称类型必填内容简介
siteId (path)UuidSite ID (UUIDv7).

请求正文

名称类型必填内容简介
domainstringThe domain or alias on the package the rule applies to.
pathstringThe path being redirected. ⛔ Named path and never sourcesource is a reserved attribute on every serializer field one layer down, and a field of that name silently reads…
destinationstringWhere the visitor is sent. A protocol-relative value is refused: it hands the customer's visitors to another server while looking like a local path.
typestring<301, 302>The redirect status. 301 is permanent and is cached by browsers and search engines; 302 is temporary. Nothing else is accepted.

响应

名称类型必填内容简介
idstringOurs, not the vendor's — this platform mints no identifier for a redirect, so this encodes the domain/type/path triple that addresses one. Opaque, stable across reads, and…
domainstringThe domain or alias the rule applies to.
pathstringThe path being redirected. ⛔ Named path and never source, which is a reserved attribute one layer down and would silently read the wrong value.
destinationstringWhere the visitor is sent.
typestring<301, 302>The redirect status — permanent or temporary.

此端点可能返回的错误

401 · 403 · 404 · 409 · 422 · 429 · 503