I have three virtual host sites enabled on apache2 all using TLS/SSL certificates. I want to redirect the non-ssl (http) to the ssl (https). I am using a redirect in each virtual host. All three .conf files are exactly the same as follows:
<VirtualHost *:80>
ServerAdmin me@gmail.com
DocumentRoot /var/www/html/site_folder/
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://www.example.com/
</VirtualHost>
...and the ssl section down here which is working fine
I realize that I do not need to specify the DocumentRoot if I am using a Redirect in this way.
The problem is that two of the virtual hosts work perfectly and always redirect to https://www.example.com as I desire. However, one site does not. It simply redirects to https://example.com (without the www.)
So, I'm totally confused about this.
I have tried enabling and disabling the site (a2ensite, a2dissite), I have tried also to copy the whole file to a new site and create a new one, and restarting apache2 and the whole server. I am completely confused about this.