# Relative URL using pathprefix

**URL:** https://community.traefik.io/t/relative-url-using-pathprefix/16757
**Category:** Traefik v2
**Tags:** kubernetes-ingress
**Created:** [December 8, 2022, 3:34pm UTC](https://community.traefik.io/t/relative-url-using-pathprefix/16757 "2022-12-08T15:34:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AllardKrings](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/allardkrings/32/4956_2.png) [@AllardKrings](https://community.traefik.io/u/AllardKrings)
#### Post date: [December 8, 2022, 3:34pm UTC](https://community.traefik.io/t/relative-url-using-pathprefix/16757/1 "2022-12-08T15:34:54Z")

</div>

Hi,

I run Traefik 2 on a kubernetens cluster (microk8s)

I am using Traefik succesfully using subdomains in front of my domainname to route to my containers.  
When I try to route based on a path I think I am stumbling on containers that serve webpages relative to root.

Example:

gitea.mydomain,com works fine.

[www.mydomain.com/gitea](http://www.mydomain.com/gitea) dos not work.

I tried to use stripprefix in a middleware but I think that is nog enough.

Is ther an aexample yaml how to do this?

Would appreciate help on this.

My route:

kind: IngressRoute  
metadata:  
name: gitea-http  
spec:  
entryPoints:  
- web  
routes:

- match: Host(`www.mydomain.com`) && PathPrefix(`/gitea/`)  
kind: Rule  
middlewares:
- name: gitea-middleware  
namespace: default  
services:
  - name: gitea  
port: 3000

My middleware:

kind: Middleware  
metadata:  
name: gitea-middleware  
spec:  
stripPrefix:  
prefixes:

- /gitea  
forceSlash: false

---

<div class="post-metadata">

### Author: ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)
#### Post date: [December 8, 2022, 4:42pm UTC](https://community.traefik.io/t/relative-url-using-pathprefix/16757/2 "2022-12-08T16:42:09Z")

</div>

This probably does not work, because the service is returning absolute URLs as redirect or links (like `/login`). You can only make it work when you can make the service path-aware, meaning it returns the correct full path.

This is why usually sub-domains are used instead of paths.

I think there is a middleware to filter and replace (regex), that would go though **all** the data returned by the service, so probably really not recommendable.
