CreateRedirect
为指定网站创建重定向规则,支持域名重定向和路径重定向。
- 路由:
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": "创建成功"}
相关接口
- GetRedirectList — 查询重定向列表
- ModifyRedirect — 修改重定向
- DeleteRedirect — 删除重定向