# Prefix / sub folder addition works, but page still doesn't load, works without adding prefix

**URL:** https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096
**Category:** Traefik v2
**Tags:** docker
**Created:** [March 17, 2021, 7:28pm UTC](https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096 "2021-03-17T19:28:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tomlawesome](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tomlawesome/32/3409_2.png) [@tomlawesome](https://community.traefik.io/u/tomlawesome)
#### Post date: [March 17, 2021, 7:28pm UTC](https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096/1 "2021-03-17T19:28:22Z")

</div>

Hola guys,

I'm trying to add labels to my Apache Guacamole container. Currently, the container can be accessed and works perfectly at its address, but I would like users to be able to navigate straight to the subdomain rather than have to manually add /guacamole.

Subdomain:

[foo.domain.com](http://foo.domain.com)

To access the web ui, Guacamole requires you to visit:

[foo.domain.com/guacamole](http://foo.domain.com/guacamole)

```auto
    labels:
      - traefik.enable=true
      - traefik.http.routers.guacamole-all.entrypoints=https,http
      - traefik.http.routers.guacamole-all.rule=Host(`sub.domain.com`)
      - traefik.http.routers.guacamole-all.rule=Path(`/`) 
      - traefik.http.middlewares.guacamole-all.redirectregex.regex=.* 
      - traefik.http.middlewares.guacamole-all.redirectregex.replacement=/guacamole
      - traefik.http.routers.guacamole-all.middlewares=guacamole-all@docker
      - traefik.http.services.guacamole-all.loadbalancer.server.port=1234

```

This does indeed change the address to:

[sub.domain.com/guacamole](http://sub.domain.com/guacamole)

But it still doesn't actually load anything? If I take the traefik redirect off again, then it works just fine...

I have also tried doing this via a file rule, and as an add prefix middlewares but couldn't get it to work. Any help greatly appreciated as I have exhausted everything I can think of/find in the docs.

---

<div class="post-metadata">

### Author: ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)
#### Post date: [March 17, 2021, 7:56pm UTC](https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096/2 "2021-03-17T19:56:14Z")

</div>

With your rule and match make your replacement `$${0}guacamole` or you're chopping off the `http(s)://sub.domain.com/`

---

<div class="post-metadata">

### Author: ![tomlawesome](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tomlawesome/32/3409_2.png) [@tomlawesome](https://community.traefik.io/u/tomlawesome)
#### Post date: [March 17, 2021, 8:43pm UTC](https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096/3 "2021-03-17T20:43:27Z")

</div>

Thanks for your reply, to confirm:

```auto
      - traefik.http.middlewares.guacamole-all.redirectregex.replacement=$${0}guacamole

```

I tried the above, but really weirdly, I'm getting another sub-domain redirecting to /guacamole?

---

<div class="post-metadata">

### Author: ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)
#### Post date: [March 17, 2021, 11:18pm UTC](https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096/4 "2021-03-17T23:18:53Z")

</div>

Your rule needs a logical &&, I missed it first time through.

` - traefik.http.routers.guacamole-all.rule=Host(`sub.domain.com`) && Path(`/`)`

---

<div class="post-metadata">

### Author: ![tomlawesome](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tomlawesome/32/3409_2.png) [@tomlawesome](https://community.traefik.io/u/tomlawesome)
#### Post date: [March 18, 2021, 12:07am UTC](https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096/5 "2021-03-18T00:07:32Z")

</div>

Thank you, this works great and it does technically answer my question. For others benefit, these are the labels:

```auto
    labels:
      - traefik.enable=true
      - traefik.http.routers.guacamole-all.entrypoints=https,http
      - traefik.http.routers.guacamole-all.rule=Host(`sub.domain.com`) && Path(`/`) 
      - traefik.http.middlewares.guacamole-all.redirectregex.regex=.* 
      - traefik.http.middlewares.guacamole-all.redirectregex.replacement=$${0}guacamole/#/
      - traefik.http.routers.guacamole-all.middlewares=guacamole-all@docker
      - traefik.http.services.guacamole-all.loadbalancer.server.port=1234

```

Where $${0} translates to this part of the string:

```auto
https://sub.domain.com/

```

But I do still have a problem, because now the domain shows 100% correct domain in full:

```auto
https://sub.domain.com/guacamole/#/

```

But the Guacamole page does not load at all -- is this related to some kind of error with http headers maybe, or problem with websocket?

---

<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: [March 21, 2021, 12:08am UTC](https://community.traefik.io/t/prefix-sub-folder-addition-works-but-page-still-doesnt-load-works-without-adding-prefix/10096/6 "2021-03-21T00:08:16Z")

</div>

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