Question background:

I have an Apache 2.4 virtual host environment hosting multiple websites in the following Ubuntu file hierarchy:

  • /var/www/site-1-folder
  • /var/www/site-2-folder
  • /var/www/site-3-folder ...etc

There is a global .htaccess file in

  • /var/www

and individual .htaccess files in each

  • /var/www/site-folder

My question: Is there an upper hierarchical limit to the Apache's .htaccess file placement?

For example: Could I place a Wordpress .htaccess set of directives in the root /var/www folder and have it applied to all the sub-folders (being individual virutal sites running Wordpress)?

I am asking because directives set in the 'global' .htaccess file don't seem to work as expected and I would like to know if either my syntax is incorrect, it is not possible, or there is an alternative.

Thanks in advance!


All the htaccess files you put on your server, provided the config allows them to be applied will be effective. The only downside is that performance degrades as the depth of the tree and hence the number of locations where a htaccess file might be found, and the number of htaccess files relevant to a particular request increases.

A "global" htaccess file is an oxymoron if you have root on the server. You should be pushing as much of the config as possible into the config files which only need to be checked when the webserver starts up; htaccess files are for when you want to provide devolved access to configuration.

  • So if I understand correctly, I could migrate .htaccess directives applicable to all virtual hosts in /etc/apache2/apache.conf and directives pertaining to individual virtual hosts in each host's respective .conf file? – Cris Tarta Mar 2 '16 at 22:22
  • Yes….....…...... – symcbean Mar 2 '16 at 22:52
  • Perfect, I'll implement your recommendations- cheers! – Cris Tarta Mar 2 '16 at 23:48

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.