Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
Ahh RegEX... Much like women.., rewarding and sweet when I figure it out... a complete uncooperative bitch when you get it wrong. –  KPWINC Nov 17 '09 at 18:59

1 Answer 1

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 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 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.