Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Apache 2.2 and let it serve domains and with <VirtualHost> statements:


My problem is, that I need to add configuration options, that are only targeted at, 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 requests only, outside the VirtualHost container?

share|improve this question
Why on heart do you want the Include statement before the VirtualHost statement? – SamK Jan 14 '11 at 14:44
I too must ask why it is that you'd wish to do this ? Your configuration directives seem to be host specific, so why can you not input them within the Vhost ? If you could expand on this, I'm sure we could come up with something. – jonathanserafini Jan 14 '11 at 14:47
Unfortunately, if it'd be only a wish, it could be simply revised. I have a piece of management software, that puts the Vhost statements at the end of httpd.conf, while allowing user-defined directives just above them. – Boldewyn Jan 14 '11 at 15:31
up vote 1 down vote accepted

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 ;-)

share|improve this answer
Hm. I think I'd rather drop the management web frontend than forking Apache. Seems like less trouble... Thanks! – Boldewyn Jan 17 '11 at 21:40
You'll find once you've got the hang of apache config files the text editor is far more powerful than any management tool, and far more secure. – dunxd Jan 19 '11 at 21:16

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.

share|improve this answer
Actually, I'm forced to use a management software, that puts user-defined config options in front of VHost statements in the main httpd.conf. I could circumvent this by manually editing httpd.conf, but then I'd lose all advantages of the web frontend that comes with the tool. – Boldewyn Jan 14 '11 at 15:32

Depending on exactly what you want to achieve .htaccess files might be what you need.

share|improve this answer
At the moment I'm trying to move as much as possible from .htaccess files to the config. Also, I'd like to specify custom log files and stuff. So, thanks for the answer, but in my case it doesn't apply unfortunately. – Boldewyn Jan 15 '11 at 9:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.