I have a primary domain: mainDomain.com , then I have several other secondary domains: prdomain.com, eventdomain.com... What I am trying to do is redirect *.prdomain.com to https://mainDomain.com/pr-marketing and *.eventdomain.com https://mainDomain.com/events
I cannot seem to figure out the correct syntax to get this to work; I need some to help with an example of how I would write this.
What I have right now:
docker-compose.yaml:
version: '3.7'
services:
mainsite:
image: my/joomla
restart: always
networks:
- frontend
volumes:
- ./html:/var/www/html
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.middlewares.mainsite-ssl.redirectscheme.scheme=https"
# http
- "traefik.http.routers.mainsite-http.rule=Host(`maindomain.com`,`www.maindomain.com`)"
- "traefik.http.routers.mainsite-http.entrypoints=web"
- "traefik.http.routers.mainsite-http.middlewares=mainsite-ssl@docker"
# https
- "traefik.http.routers.mainsite.rule=Host(`maindomain.com`,`www.maindomain.com`)"
- "traefik.http.routers.mainsite.middlewares=secureHeader@file"
- "traefik.http.routers.mainsite.entrypoints=websecure"
# Lets Encrypt
- "traefik.http.routers.mainsite.tls=true"
- "traefik.http.routers.mainsite.tls.certresolver=le-tls"
#redirects:
- "traefik.http.middlewares.pr-redirect.redirectregex.regex=^https?://(www[.])?prdomain[.]com.*"
- "traefik.http.middlewares.pr-redirect.redirectregex.replacement=https://maindomain.com/pr-marketing"
- "traefik.http.routers.prsite.rule=HostRegexp(`{subdomain:[a-z]+}.prdomain.com`)"
- "traefik.http.routers.prsite.middlewares=pr-redirect@docker"
networks:
frontend:
external:
name: traefik