title: redirect all subdomains from http to https
body: <p>I redirect all http requests for my subdomain to https by using following code.</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
    ServerName subdomain.example.com
    Redirect 302 / https://subdomain.example.com
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Now my problem is how do I do it for all subdomains.</p>
  
  <p>For example http:subdomain1.example.com should go to https:subdomain1.example.com and http:subdomain2.example.com should go to https:subdomain2.example.com</p>
  
  <p>How do I do it for all subdomains without having to create one virtualhost for all of them</p>
  
  <p><strong>Update</strong></p>
  
  <p>I found that RedirectMatch takes regular expression. Does anyone know how to do it using regex?</p>