title: Apache Virtual Host: HTTP getting redirected to the default Apache site
body: <p>I have hosted an website on a VPS using Apache Virtual Server, as I plan to host a few more sites on that VPS later on. The virtual host was working properly until I installed SSL on it using the LetsEncrypt Certbot. After doing that, <a href="https://techkernel.org" rel="nofollow noreferrer">https://techkernel.org</a> works fine, but the http variant, <a href="http://techkernel.org" rel="nofollow noreferrer">http://techkernel.org</a> gets redirected to the default Apache webpage. The virtual host configurations aren't working properly and it's getting directed to the default /var/www/html directory.</p>
  
  <p>If you could tell me how to fix it so that both HTTP and HTTPS requests get redirected to HTTPS and also show the correct website, that would be much helpful. Thank you.</p>
  
  <p><strong>Relevant information:</strong></p>
  
  <p><em>etc/apache2/sites-available/techkernel.org.conf</em></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      # The ServerName directive sets the request scheme, hostname and port that
      # the server uses to identify itself. This is used when creating
      # redirection URLs. In the context of virtual hosts, the ServerName
      # specifies what hostname must appear in the request's Host: header to
      # match this virtual host. For the default virtual host (this file) this
      # value is not decisive as it is used as a last resort host regardless.
      # However, you must set it for any further virtual host explicitly.
      ServerName www.techkernel.org
  
      ServerAdmin webmaster@localhost
      DocumentRoot "/var/www/techkernel.org/public"
  
      ServerAlias techkernel.org
  
      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
      # error, crit, alert, emerg.
      # It is also possible to configure the loglevel for particular
      # modules, e.g.
      #LogLevel info ssl:warn
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
      # For most configuration files from conf-available/, which are
      # enabled or disabled at a global level, it is possible to
      # include a line for only one particular virtual host. For example the
      # following line enables the CGI configuration for this host only
      # after it has been globally disabled with "a2disconf".
  
      Include conf-available/serve-cgi-bin.conf
      RewriteEngine on
      RewriteCond %{SERVER_NAME} =www.techkernel.org [OR]
      RewriteCond %{SERVER_NAME} =techkernel.org
      RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
  
  &lt;/VirtualHost&gt;
  
  # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  </code></pre>
  
  <p><em>var/www/techkernel.org/public/.htaccess</em></p>
  
  <pre><code># BEGIN WordPress
  &lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L]
  
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  &lt;/IfModule&gt;
  
  # END WordPress
  </code></pre>
  
  <p><em>ls -l /etc/apache2/sites-enabled</em></p>
  
  <pre><code>lrwxrwxrwx 1 root root 35 Dec 28 11:08 000-default.conf -&gt; ../sites-available/000-default.conf
  lrwxrwxrwx 1 root root 38 Jan 21 04:31 techkernel.org.conf -&gt; ../sites-available/techkernel.org.conf
  lrwxrwxrwx 1 root root 55 Dec 28 19:46 techkernel.org-le-ssl.conf -&gt; /etc/apache2/sites-available/techkernel.org-le-ssl.conf
  </code></pre>
  
  <p><em>ls -l /etc/apache2/sites-enabled</em></p>
  
  <pre><code>-rw-r--r-- 1 root root 1332 Jul  5  2016 000-default.conf                                                                                                           
  -rw-r--r-- 1 root root 6437 Aug  7 10:56 default-ssl.conf                                                                                                           
  -rw-r--r-- 1 root root 1574 Jan 19 16:05 techkernel.org.conf                                                                                                        
  -rw-r--r-- 1 root root 1613 Dec 28 19:46 techkernel.org-le-ssl.conf
  </code></pre>