# Strip part of URI

**URL:** <https://discuss.konghq.com/t/strip-part-of-uri/2738>\
**Category:** Feature Requests & Feedback\
**Created:** [February 1, 2019, 4:17pm UTC](https://discuss.konghq.com/t/strip-part-of-uri/2738 "2019-02-01T16:17:45Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![rsemlal.tas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/rsemlal.tas/32/3091_2.png) [@rsemlal.tas](https://discuss.konghq.com/u/rsemlal.tas)\
**Post date:** [November 10, 2021, 8:47am UTC](https://discuss.konghq.com/t/strip-part-of-uri/2738/10 "2021-11-10T08:47:01Z")

</div>

Since it took me a while to figure things out, I thought sharing my solution might help

For the record, I had the same problem, I end up using:

- The plugin [GitHub - alexashley/kong-plugin-path-prefix: A Kong plugin to rewrite the upstream request path](https://github.com/alexashley/kong-plugin-path-prefix) to strip the path prefix
- The _post-function_ plugin to set the `X-Forwarded-Prefix` properly

Full example with Kong Ingress Controller

```auto
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: strip-demo-2-path-prefix
config:
  path_prefix: "/foo/"
plugin: path-prefix
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: set-forwarded-header
plugin: post-function
config:
  access:
    - |
      ngx.var.upstream_x_forwarded_prefix='/foo'
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo-2
  annotations:
    konghq.com/strip-path: "false"
    konghq.com/plugins: strip-demo-2-path-prefix,set-forwarded-header
spec:
  ingressClassName: kong
  rules:
  - http:
      paths:
      - backend:
          service:
            name: echo
            port:
              number: 80
        path: /foo/bar
        pathType: ImplementationSpecific

```

With this solution:

- Requests to `/foo/bar` are captured by Kong
- They are routed to the upstream service to the path `/bar`
- The forwarded request has the header `X-Forwarded-Prefix: /foo` (which makes the upstream service able to find out what its external url is)

---

_[View the full topic](https://discuss.konghq.com/t/strip-part-of-uri/2738)._
