apache Force HTTPS using virtual host


Use Redirect to force users to connect to the secure URL.

<VirtualHost *:80>
    ServerName example.com
    SSLProxyEngine on
    Redirect permanent / https://secure_example.com/

The rest of the configuration can be put in the ssl virtual host (port 443) since everything is redirected.

<VirtualHost _default_:443>
    ServerName secure_example.com
    ServerAdmin webmaster@example.com 
    DocumentRoot /var/www/domains/secure_example.com/html
    ErrorLog /var/log/secure_example.com/error.log
    CustomLog /var/log/secure_example.com/access.log common
    SSLEngine On