title: Automatic lets encrypt SSL certificate for wildcard subdomain
body: <p>I am using ISPConfig as hosting panel on my Centos VPS Machine and Cloudflare for DNS management.</p>
  
  <p>I have added the following rewrite rules to my vhost which automatically reroutes sub-folders to sub-domains.</p>
  
  <p>Code:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www\.domain.com
  RewriteCond %{HTTP_HOST} ^(www\.)?(([^\.]+)\.){1}domain..com$
  RewriteCond /var/www/backoffice.ge/web/build/%3 -d
  </code></pre>
  
  <p>All works fine and perfect on http (*80), but i have certificate issue on https (*443). Based on my workaround, issue is in Let's Encrypt certificate which is generated for main domain only (domain.com). </p>
  
  <p>If possible, i want to create universal wildcard certificate which will automatically work for all sub domains, or create sub domain/directory certificates on the fly via PHP.</p>
  
  <p>I have found some articles about Certbot. But, not sure how to make it work for the above setup.</p>