apache How to create virtual host in Apache Force HTTPS using virtual host

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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

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

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
    ...
</VirtualHost>


Got any apache Question?