Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a directory in my webserver for which I would like to serve up only pdf files. I found I can restrict access using the .htaccess, and using something like

<FilesMatch "\.(text,doc)">
  Order allow,deny
  Deny from all
  Satisfy All
</FilesMatch>

to serve up everything except a regular expression. Is it possible to instead restrict access to only files which meet some regular expression?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

I'm not personally familiar with the approach you're taking, but to give you a general direction to look...

You should be able to set a general deny all for all files in the directory. Then, you can use the block in your original post to give specific allow access to the filetypes matching the regex you want, using filesmatch. Something along those lines should work. Someone else may be able to provide specific code for it, I just am not familiar enough with apache's syntax to figure it out off the top of my head.

share|improve this answer
add comment

Your Answer

 
discard

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.