URL重定向-创建
接口信息
- 接口地址:
{your-site-url}/api/skill/redirect/create
- 基础 URL:
{your-site-url} 需替换为你自己的独立站 URL 地址,如 https://your-domain.com/apimanager666
- 请求方式:
POST
- 说明: 此接口用于手动创建一个 URL 重定向规则。创建后,当用户访问
path 时将被自动重定向到 target。
认证
请求头中需要携带 skill-access-token:
| Header |
值 |
skill-access-token |
{your-skill-access-token} (请替换为你自己的 token) |
Content-Type |
application/json |
请求参数 (JSON Body)
| 字段 |
类型 |
必填 |
说明 |
path |
string |
是 |
要重定向的旧路径。当用户访问此路径时将被重定向 |
target |
string |
是 |
重定向的目标路径。可以是站内路径或外部 URL |
请求示例
cURL
curl --location --request POST '{your-site-url}/api/skill/redirect/create' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"path": "/products/xxxxx1",
"target": "/products/yyyyy1"
}'
返回结果
code 为 200 表示调用成功;code 不为 200 表示调用失败。
成功响应
{
"code": 200,
"data": {
"shop_id": 15,
"path": "/products/xxxxx1",
"target": "/products/yyyyy1",
"o_id": 0,
"type": 10,
"created_at": "2026-06-04 11:32:13",
"updated_at": "2026-06-04 11:32:13",
"id": 489
},
"message": "success"
}
返回字段说明
| 字段 |
类型 |
说明 |
code |
Number |
状态码,200 表示成功 |
message |
String |
执行结果的文字描述 |
data.id |
int |
新创建的重定向记录 ID |
data.shop_id |
int |
店铺 ID |
data.path |
string |
旧路径 |
data.target |
string |
目标路径 |
data.type |
int |
重定向类型。手动创建固定为 10 |
data.o_id |
int |
对应实体 ID。手动创建固定为 0 |
data.created_at |
string |
创建时间 |
data.updated_at |
string |
最后更新时间 |
注意事项
- 通过此 API 创建的重定向为手动类型(
type = 10,o_id = 0)
target 可以是站内路径(如 /products/xxx)或外部 URL(如 https://example.com)
- 系统自动生成的重定向(type 1~5)由修改商品/页面/博客 handle 时自动产生,不通过此接口