Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I have to duplicate the Virtualhost directives for port 80 and 443?

I have a long and intricate list of <VirtualHost> directives, and I have to duplicate them into separate <VirtualHost> groups for ports 80 and 443 because I'm using SSL. Whenever I update my mod_rewrite rules I have to remember to do it in both places or else I'll break my app... this duplication is asking for trouble. Is there a way to combine or alias these -- the only difference between the two is that the port 443 version contains the SSLEngine, SSLCertificateFile and the like.

My <Virtualhost> contains many mod_rewrite rules, LocationMatch rules, CGI directives, etc.

Also, I can't use .htaccess files.

like image 859
scotts Avatar asked Mar 24 '09 21:03

scotts


People also ask

What is VirtualHost * 80?

VirtualHost directive allows you to configure and use multiple sites located on the same IP address. In this case, with *:80 you are creating a virtual host for every request coming on the port 80. It becomes more interesting when you start specializing and start to insert something other than * in the virtual host.

What is a VirtualHost Apache?

A Virtual Host is an Apache configuration directive that allows you to run more than one website on a single server. With Virtual Hosts, you can specify the site document root (the directory containing the website files), create a separate security policy for each site, use different SSL certificates, and much more.


1 Answers

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>   
like image 130
sfossen Avatar answered Sep 25 '22 01:09

sfossen