title: Apache redirection of both http to https and non www to www
body: <p>I'm having an issue with apache2. I would like to redirect both port 80 to port 443 but also redirect non www to www. </p>
  
  <p>In the following config I have the http to https redirection working fine:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      Redirect permanent / https://www.example.com/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:443&gt;
      ServerName www.example.com
      DirectoryIndex index.html
      ...
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>The problem is this I can redirect http to https fine, however when I go to <code>https://example.com</code> it does not redirect to <code>https://www.example.com</code></p>
  
  <p>Can anyone help me with this issue?</p>