Do I have to duplicate the Virtualhost directives for port 80 and 443?
Solution 1:
Can't you use an include directive to include the common rules. here
article
eg.:
<VirtualHost _default_:80>
...
include conf/common_rule.conf
</VirtualHost>
<VirtualHost _default_:*>
...
include conf/common_rule.conf
</VirtualHost>
<VirtualHost _default_:443>
... #SSL rules
include conf/common_rule.conf
</VirtualHost>
Solution 2:
You can use any # of hosts and ports in a single Virtualhost directive.
<VirtualHost addr[:port] [addr[:port]] ...> ... </VirtualHost>
In My case I used.
<VirtualHost *:80 *:443>
ServerName loop.lk
....
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/local.crt
</VirtualHost>