title: Rewrite any subdomain to https
body: <p>Currently I am running a little web server with apache on my LAMP system. I already created a https certificate for my domain. Now I would like to rewrite any subdomain and directory of subdomain to https without www. I already have a code in my .htaccess file and it rewrites the www version to non www and to https.</p>
  
  <p>Here's the code in my .htaccess file (located in the root apache directory):</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
  </code></pre>
  
  <p>I already tried to just exchange the "www" with "(.*)" but I am not sure what "%1" and "$1" does because I found that code in the internet and they didn't explained it. I researched about regular expressions but I can't find anything.</p>