首页 > 解决方案 > Kong Regex 用于替换 URI 中的字符串

问题描述

我正面临一个可用的“strip_path”功能的特殊问题

**Service Name**: application-svc
**Service Path**: /application

**Route for Service**: application-route
**Route Path**: /
**Strip_Path**: True

**Backend API**: /openapi

**Expected**:
calls made to www.xyz.com/applications/openapi will transform the url
from:  www.xyz.com/applications/openapi
to: www.xyz.com/openapi

**Actual Result**:
calls made to www.xyz.com/applications/openapi end up with  www.xyz.com/applicationsapplications/openapi

有人可以帮忙吗?

标签: kongkong-pluginkong-ingresskonga

解决方案


Strip_Path 与 Route Path 相关,而不是 Route 和 Service Path。

要解决您的问题,请使用以下命令:

**Service Name**: application-svc
**Service Path**: 

**Route for Service**: application-route
**Route Path**: /applications
**Strip_Path**: True

**Backend API**: /openapi

**Expected**:
calls made to www.xyz.com/applications/openapi will transform the url
from:  www.xyz.com/applications/openapi
to: www.xyz.com/openapi

**Actual Result**:
calls made to www.xyz.com/applications/openapi end up with
www.xyz.com/openapi

推荐阅读