Edit your dynamic_config.yml in the config/traefik directory of your Pangolin stack.
middlewares:
redirect-subdomains-to-domain2:
redirectRegex:
# foo.old-example.com/bar -> https://foo.new-example.com/bar
regex: ^https?://([^.]+(?:\.[^.]+)*)\.old-example\.com(.*)
replacement: https://$1.new-example.com$2
permanent: true
redirect-apex-to-domain2:
redirectRegex:
regex: ^https?://old-example\.com(.*)
replacement: https://new-example.com$1
permanent: true- Replace
old-example.comwith your source domain (e.g.,foo.com) - Replace
new-example.comwith your destination domain (e.g.,example.com)
routers:
# Subdomains (HTTP)
r-sub-http:
rule: "HostRegexp(`.+\\.old-example\\.com`)"
entryPoints: ["web"]
middlewares: ["redirect-subdomains-to-domain2"]
service: "noop@internal"
priority: 3000
# Subdomains (HTTPS)
r-sub-https:
rule: "HostRegexp(`.+\\.old-example\\.com`)"
entryPoints: ["websecure"]
tls: {}
middlewares: ["redirect-subdomains-to-domain2"]
service: "noop@internal"
priority: 3000
# Apex (HTTP)
r-apex-http:
rule: "Host(`old-example.com`)"
entryPoints: ["web"]
middlewares: ["redirect-apex-to-domain2"]
service: "noop@internal"
priority: 3000
# Apex (HTTPS)
r-apex-https:
rule: "Host(`old-example.com`)"
entryPoints: ["websecure"]
tls: {}
middlewares: ["redirect-apex-to-domain2"]
service: "noop@internal"
priority: 3000services:
noop:
loadBalancer:
servers:
- url: http://127.0.0.1docker restart traefikcurl -Ik https://localhost:443 -H 'Host: api.old-example.com'Expected Output:
HTTP/2 308
location: https://api.new-example.com/
content-length: 18
date: Wed, 13 Aug 2025 18:15:40 GMT