I've got a set of virtual hosts that need separate vhost definitions for *:80 and *:443. After creating these, I've found that I've got 20-40 configuration parameters that both *:80 and *:443 share; Is there a way to specify these once and have them shared, rather than twice (once in each VirtualHost definition?)
2 Answers
Just create a separate config file fragment containing the shared directives and Include
it from both virtual host definitions. (Make sure it's placed someplace where Apache won't try to include it by itself, like it would a .conf
file in a conf.d
directory.)
Rewriting in Virtual Hosts
#By default, mod_rewrite configuration settings from the main
#server context are not inherited by virtual hosts.
#To make the main server settings apply to virtual hosts,
#place the following directives in each <VirtualHost> section:
#
RewriteEngine On
RewriteOptions Inherit
#