Skip to content

为网站创建 301/302 重定向规则

为指定网站创建重定向规则,支持域名重定向和路径重定向。

POST
https://your-panel.example.com:8888/site
更新于 查看 Markdown

Request bodyX-WWW-FORM-URLENCODEDrequired

  • request_timestringrequired

    Unix 时间戳。

  • request_tokenstringrequired

    按 API 概览生成的签名。

  • actionCreateRedirectrequired

    具体操作名称。

  • sitenamestringrequired

    网站域名(注意小写)

  • redirectnamestringrequired

    重定向名称(唯一标识)

  • tourlstringrequired

    目标 URL

  • redirectdomainstringrequired

    JSON 数组,来源域名列表 ["old.example.com"]

  • redirectpathstringrequired

    来源路径,如 / 或 /old-path

  • redirecttypestringrequired

    重定向类型:"path" / "domain"

  • typestringrequired

    "0" 启用 / "1" 301 永久

  • domainorpathstringrequired

    "path" 路径重定向 / "domain" 域名重定向

  • holdpathstringrequired

    "1" 保留路径 / "0" 不保留

Returns

default

接口响应,业务状态见下方详细说明。

JSON
  • statusoptionalboolean

    true 创建成功

各操作详细说明

CreateRedirectaction=CreateRedirect为网站创建 301/302 重定向规则

为指定网站创建重定向规则,支持域名重定向和路径重定向。

  • 路由:POST /site
  • action:CreateRedirect

输入参数

参数名称 必选 类型 描述
action 是 String 固定值 CreateRedirect
sitename 是 String 网站域名(注意小写)
redirectname 是 String 重定向名称(唯一标识)
tourl 是 String 目标 URL
redirectdomain 是 String JSON 数组,来源域名列表 ["old.example.com"]
redirectpath 是 String 来源路径,如 / 或 /old-path
redirecttype 是 String 重定向类型:"path" / "domain"
type 是 String "0" 启用 / "1" 301 永久
domainorpath 是 String "path" 路径重定向 / "domain" 域名重定向
holdpath 是 String "1" 保留路径 / "0" 不保留

输出参数

参数名称 类型 描述
status Boolean true 创建成功

示例

请求

POST /site HTTP/1.1
Host: 192.168.168.213:8888
Content-Type: application/x-www-form-urlencoded

action=CreateRedirect&sitename=testapi.bt.local&redirectname=old_site&tourl=http://example.com&redirectdomain=["old.example.com"]&redirectpath=/&redirecttype=path&type=0&domainorpath=path&holdpath=0

响应

{"status": true, "msg": "创建成功"}

相关接口

Navigation

Type to search…

↑↓ navigate↵ selectEsc close