Ini contoh settingan vhost dengan use case apabila domain diakses melalui protocol http akan direwrite menjadi https.
<VirtualHost *:80>
ServerAdmin kumkum@localhost
ServerName mystique-inventory.binajaya.com
ServerAlias www.mystique-inventory.binajaya.com
ErrorLog ${APACHE_LOG_DIR}/mystique-inventory.binajaya-itsolution.com_error.log
CustomLog ${APACHE_LOG_DIR}/mystique-inventory.binajaya-itsolution.com_access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mystique-inventory.binajaya.com [OR]
RewriteCond %{SERVER_NAME} =mystique-inventory.binajaya.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin kumkum@localhost
ServerName mystique-inventory.binajaya.com
ServerAlias www.mystique-inventory.binajaya.com
DocumentRoot /var/www/html/mystique-inventory
<Directory /var/www/html/mystique-inventory>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/mystique-inventory.binajaya.com_error.log
CustomLog ${APACHE_LOG_DIR}/mystique-inventory.binajaya.com_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/mystique/mystique.crt
SSLCertificateKeyFile /etc/ssl/mystique/mystique.key
#SSLCertificateChainFile /etc/ssl/mystique/ca-bundle.crt
</VirtualHost>
setelah dibuat filenya, ingat enable conf nya dengan command a2ensite pada ubuntu, dan service apache2 reload