Here's a simple technique on how I learned to redirect a site from HTTP to HTTPS automatically using Apache's VirtualHost configuration.

Go to your configuration file or 000-default.conf and modify your configuration to something like this:

<VirtualHost *:80>
    Redirect permanent /

<VirtualHost *:443>
    SSLEngine On
    # insert code here...

Save the file and check if the configuration is correct before your restart the server:

sudo apachectl configtest

If you get the message, Syntax OK, then go ahead and restart the server:

sudo systemctl restart apache2

Now, your visitors will be redirected from HTTP to HTTPS automatically!

Hope you found this tip useful!