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 trying to find the most performance friendly way of denying access to specific files and folders via htaccess. (For example a .git folder, an .hg folder, the .htaccess file itself.) Is there some particlaur method, or combination, that is more performance friendly than the others? (FilesMatch vs DirectoryMatch vs RedirectMatch vs whatever.)

share|improve this question
up vote 1 down vote accepted

In an .htaccess file, the performance difference between any of those is negligible. They all do filesystem stat calls, which is the "expensive" part.

For the best performance, if you can, use LocationMatch directly in the VirtualHost of your Apache httpd configuration.

share|improve this answer
The httpd file is out of the question. Even negligible gains or losses are important here. – Joshua Walker Jul 26 '11 at 17:58
But regardless, thank you for posting an answer. – Joshua Walker Aug 23 '12 at 19:19

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.