# Traefik HostRegexp Rule for multidomain name

**URL:** <https://community.traefik.io/t/traefik-hostregexp-rule-for-multidomain-name/18674>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [May 19, 2023, 2:10pm UTC](https://community.traefik.io/t/traefik-hostregexp-rule-for-multidomain-name/18674 "2023-05-19T14:10:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smithpl](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@smithpl](https://community.traefik.io/u/smithpl)\
**Post date:** [May 19, 2023, 2:10pm UTC](https://community.traefik.io/t/traefik-hostregexp-rule-for-multidomain-name/18674/1 "2023-05-19T14:10:59Z")

</div>

Hi,  
I've just created an nginx container for website with rule Host. It work well.

I would like to change it to works with HostRegexp for multidomain requests.  
I want to have one website for serveral subdomains but regexp doesn't work.

Domains  
[name.subdomain.domain.com](http://name.subdomain.domain.com)  
[name.subdomain2.domain.com](http://name.subdomain2.domain.com)  
[name.domain.com](http://name.domain.com)

I try tu use this rule in my docker-compose file:  
labels:  
- "traefik.enable=true"  
- "traefik.http.routers.web.rule=HostRegexp(`name(.subdomain|subdomain2|.)domain.com`)"

or

labels:  
- "traefik.enable=true"  
- "traefik.http.routers.web.rule=HostRegexp(`name.(subdomain|subdomain2|).domain.com`)"

Both rules are not working. How to do this well?

---

<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:** [May 19, 2023, 6:41pm UTC](https://community.traefik.io/t/traefik-hostregexp-rule-for-multidomain-name/18674/2 "2023-05-19T18:41:35Z")

</div>

Use "or":

```auto
.rule=Host(`example.com`) || Host(`sub.abc.com`)

```

---

<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:** [May 14, 2025, 11:06am UTC](https://community.traefik.io/t/traefik-hostregexp-rule-for-multidomain-name/18674/3 "2025-05-14T11:06:21Z")

</div>

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