I can't find anywhere which states if I can set a default virtual host config. I know you have 000-default.conf which is used when no vHost is found, but what about if I want to set a default config on all directories within /var/www?

Say if I want to use this "default" global virtual host file to set Options -Indexes, I would then want Apache to set this on any directory in /var/www unless stated otherwise by the virtual host of the domain name.

Is this something that is possible, if so could you show me how?


If you want to set a default configuration for /var/www directory that applies to any virtualhost you define unless it was manually defined somewhere else, then you have to define this directory configuration in the previous hierarchical context to Virtualhost, that is, server config (global configuration).

For instance, if you don't want Indexes enabled by default for the documentroot path in /var/www, and your main configuration file is httpd.conf or apache2.conf, there you just have to add:

<Directory /var/www>
Options -Indexes
#any other config here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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