Apache virtualhost: redirect a vhost from port 80 to 443 (ssl)

To redirect access to starndard www port to https one you’ve to change the default vhost configuration from VirtualHost *:80 to VirtualHost *:443 and add the “redirect section”:

I’ve added this:

<VirtualHost *:80>
ServerName example.twopenguins.it
ServerAlias www.example.twopenguins.it
<Location />
Redirect permanent / https://example.twopenguins.it
</Location>
</VirtualHost>

And changed the “old” section from :80 to :443:

<VirtualHost *:443>
ServerName example.twopenguins.it
ServerAlias www.example.twopenguins.it
SSLEngine on
ecc.. ecc..

Reload and you’re done.