title: Traefik Redirect Domain to Subdomain
body: <p>I want to permanently redirect all requests to <code>example.com</code> and <code>www.example.com</code> to <code>blog.example.com</code> in a TLS environment.</p>
  <p>My current config:</p>
  <p><em>traefik.toml</em>:</p>
  <pre><code>[entryPoints]
    [entryPoints.web]
      address = &quot;:80&quot;
      [entryPoints.web.http.redirections.entryPoint]
        to = &quot;websecure&quot;
        scheme = &quot;https&quot;
  
    [entryPoints.websecure]
      address = &quot;:443&quot;
  
  [providers.docker]
    exposedbydefault = false
    watch = true
    network = &quot;web&quot;
  [providers.file]
    filename = &quot;traefik_dynamic.toml&quot;
  
  [certificatesResolvers.lets-encrypt.acme]
    email = &quot;mymail@example.com&quot;
    storage = &quot;/letsencrypt/acme.json&quot;
    [certificatesResolvers.lets-encrypt.acme.dnsChallenge]
      provider = &quot;myprovider&quot;
  </code></pre>
  <p><em>traefik_dynamic.toml</em>:</p>
  <pre><code>[http.middlewares] 
    [http.middlewares.goToBlog.redirectregex] 
      regex = &quot;^https://(.*)example.com/(.*)&quot; 
      replacement = &quot;https://blog.example.com/$${2}&quot;
      permanent = true
   
  [http.routers] 
    [http.routers.gotoblog] 
      rule = &quot;Host(`example.com`) || Host(`www.example.com`)&quot; 
      entrypoints = [&quot;websecure&quot;] 
      middlewares = [&quot;goToBlog&quot;] 
      service = &quot;noop@internal&quot; 
      [http.routers.gotoblog.tls] 
        certResolver = &quot;lets-encrypt&quot;
  </code></pre>
  <p>When I try to access <code>example.com</code> it gives my an SSL Protocol Error. All my other endpoints including <code>blog.example.com</code> are working. What am I doing wrong?</p>