Super User is a question and answer site for computer enthusiasts and power users. 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 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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .