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?
No, you can't. This is exactly what VirtualHost blocks are for. If you can give us a more thorough description of exactly what problem you're trying to solve, we may be able to suggest some alternatives.
Depending on exactly what you want to achieve .htaccess files might be what you need.
So VirtualHosts directives and .htaccess files are out of the question. So the only thing left is to run a different instance of Apache for each subdomain, which would have a completely separate configuration file, which might potentially work with your management software.
If none of those work for you, then you have drifted so far from the standard way of doing things that you probably need to write your own fork of Apache to deal with your specific requirements ;-)