How can I add config options for a specific hostname outside <VirtualHost>?

Posted by Boldewyn on Server Fault See other posts from Server Fault or by Boldewyn
Published on 2011-01-14T14:36:16Z Indexed on 2011/01/14 14:55 UTC
Read the original article Hit count: 253

I'm using Apache 2.2 and let it serve domains foo.example.com and bar.example.com with <VirtualHost> statements:

<VirtualHost 127.0.0.1:80>
  ServerName foo.example.com
</VirtualHost>
<VirtualHost 127.0.0.1:80>
  ServerName bar.example.com
</VirtualHost>

My problem is, that I need to add configuration options, that are only targeted at foo.example.com, in a separate file (let's say, /etc/apache/sites-enabled/foo.conf). This file will be included, before the VirtualHost statement is issued, but it can't be embedded inside it.

Can I (and if yes, how) target configuration settings to foo.example.com requests only, outside the VirtualHost container?

© Server Fault or respective owner

Related posts about apache

Related posts about configuration