跳到正文
Navigation

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

POST
https://your-panel.example.com:8888/site

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

Request body application/x-www-form-urlencoded required

  • request_time
    string
    required

    Unix 时间戳。

  • request_token
    string
    required

    按 API 概览生成的签名。

  • action
    CreateRedirect
    required

    具体操作名称。

  • sitename
    string
    required

    网站域名(注意小写)

  • redirectname
    string
    required

    重定向名称(唯一标识)

  • tourl
    string
    required

    目标 URL

  • redirectdomain
    string
    required

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

  • redirectpath
    string
    required

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

  • redirecttype
    string
    required

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

  • type
    string
    required

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

  • domainorpath
    string
    required

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

  • holdpath
    string
    required

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

Returns

default

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

JSON
  • status
    optional
    boolean

    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": "创建成功"}

相关接口

Type to search…

↑↓ navigate↵ selectEsc close