# PathPrefix won't work

**URL:** <https://community.traefik.io/t/pathprefix-wont-work/26567>\
**Category:** Traefik v3 (latest)\
**Tags:** docker\
**Created:** [February 19, 2025, 6:28pm UTC](https://community.traefik.io/t/pathprefix-wont-work/26567 "2025-02-19T18:28:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerom](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Jerom](https://community.traefik.io/u/Jerom)\
**Post date:** [February 19, 2025, 6:28pm UTC](https://community.traefik.io/t/pathprefix-wont-work/26567/1 "2025-02-19T18:28:44Z")

</div>

Hi there!  
I'm discovering Traefik through docker and I have an issue I can't resolve.  
Sorry if I'm making a double!

I have a docker-compose.yml for traefik and another one for a server with php-mysql-phpmyadmin.  
Everything works fine but I can't reach phpmyadmin's main page.  
I'm trying everything on a sub-domain that will be called... '[sub.domain.com](http://sub.domain.com)'!  
I'm trying to reach phpmyadmin through '[sub.domain.com/phpmyadmin](http://sub.domain.com/phpmyadmin).  
Here is my yml for php-mysql-phpmyadmin:

```auto
services:
  mysql:
    image: mysql:latest
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: mydatabase
      MYSQL_USER: myuser
      MYSQL_PASSWORD: mypassword
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - web_test
  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    links:
      - mysql
    ports:
      - 8081:80
    environment:
      PMA_HOST: mysql
      MYSQL_USERNAME: root
      MYSQL_ROOT_PASSWORD: secret
    networks:
      - web_test
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.phpmyadmin.rule=(Host(`sub.domain.com`) && PathPrefix(`/phpmyadmin`))"
  php:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ./src:/var/www/html
    ports:
      - 8085:80
    depends_on:
      - mysql
    networks:
      - web_test
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.php.rule=(Host(`sub.domain.com`))"

volumes:
  mysql_data:

networks:
  web_test:
    external: true

```

and here my docker-compose for traefik:

```auto
networks:
  web_test:
    external: true

services:
  traefik:
    image: "traefik:latest"
    container_name: "traefik"
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entryPoints.web.address=:8082"
    ports:
      - "8082:80"
      - "8086:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks:
      - web_test

```

When I try [https://sub.domain.com](https://sub.domain.com), I reach my index.php  
but [https://sub.domain.com/phpmyadmin](https://sub.domain.com/phpmyadmin) gives me a 404 error (not found)

I think I forgot something but I don't find what! If someone can help...  
Thank you very much and sorry for my bad english...

---

<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:** [February 19, 2025, 6:55pm UTC](https://community.traefik.io/t/pathprefix-wont-work/26567/2 "2025-02-19T18:55:12Z")

</div>

Why do you think it should work?

[Doc](https://hub.docker.com/_/phpmyadmin) states

> All of the following examples will bring you phpMyAdmin on `http://localhost:8080`

so the app expects to be root (`/`).

If you access the service with unknown path `/phpmyadmin` (which will be forwarded to the service), it will return 404. It’s that simple.

Best practice is to use sub-domains for services instead, check [simple Traefik example](https://github.com/bluepuma77/traefik-best-practice/tree/main/docker-traefik-dashboard-letsencrypt).

---

<div class="post-metadata">

**Author:** ![Jerom](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Jerom](https://community.traefik.io/u/Jerom)\
**Post date:** [February 19, 2025, 8:13pm UTC](https://community.traefik.io/t/pathprefix-wont-work/26567/3 "2025-02-19T20:13:55Z")

</div>

Thank you very much!  
Using [sub2.domain.com](http://sub2.domain.com) (root) works very well!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [February 22, 2025, 8:13pm UTC](https://community.traefik.io/t/pathprefix-wont-work/26567/4 "2025-02-22T20:13:58Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
