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

We serve up our pages with Apache 2.2 on Windows. We'd like to disallow viewing of pages with the .txt extension. How can we do something like that?

Another option which would arguably be even better would be to have a list of filetypes that are allowed to be served statically.


Just FYI: My original issue was mostly just because my file regex was wrong.

share|improve this question
up vote 4 down vote accepted

Take a look at this:

hope this helps.

share|improve this answer
Sorry, this is for apache 1.3 and 2.0. This won't work for 2.2 – Frew Schmidt Nov 16 '09 at 23:37
Did actually you test that Frew? This works for me on Apache 2.2.9. – Zoredache Nov 17 '09 at 1:15
Yeah, I tested it, it just seems to show the files just fine :-/ – Frew Schmidt Nov 17 '09 at 15:11
Frew: no offense, but you're doing something wrong. It works. – Bill Weiss Nov 17 '09 at 16:32
@KPWINC: it works perfecly even under Apache 2.2.19, thank you so much for sharing such an interesting link, and obviously +1 – Marco Demaio Aug 23 '11 at 17:57

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.