title: traefik - HTTP to HTTPS WWW Redirect
body: <p>I could not find a question similar to this, there were others mentioning https redirects, but not about minimizing the redirects.</p>
  
  <p>Been looking for a solution, and could not sort it out yet.</p>
  
  <p>We use Docker > Traefik for WordPress and have www as the preferred version for WordPress. There are multiple WP instances. Domains are added dynamically. </p>
  
  <p>However, with this config, I am receiving two redirects, from http to https to https www </p>
  
  <pre><code>http://example.com/
  https://example.com/
  https://www.example.com/
  </code></pre>
  
  <p>Is there any way to minimize the redirect? </p>
  
  <p>ideally <strong>a 301 redirect</strong> from</p>
  
  <pre><code>http://example.com directly to https://www.example.com 
  </code></pre>
  
  <p><strong>Traefik config file as follows</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>defaultEntryPoints = ["http", "https"]
  
  [web]
  address = ":8080"
  
  [entryPoints]
  
  [entryPoints.http]
  address = ":80"
  [entryPoints.http.redirect]
  entryPoint = "https"
  
  [entryPoints.https]
  address = ":443"
  compress = true
  [entryPoints.https.tls]
  
  [acme]
  email = "email@domain.com"
  storage = "acme.json"
  entryPoint = "https"
  onDemand = false
  OnHostRule = true
  
  
  [docker]
  endpoint = "unix:///var/run/docker.sock"
  domain = "traefik.example.com"
  watch = true
  exposedbydefault = false</code></pre>
  </div>
  </div>
  </p>