.htaccess to restrict access to only select files

0

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?

Bryan Ward

Posted 2010-06-16T04:13:22.390

Reputation: 563

Answers

1

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.

nhinkle

Posted 2010-06-16T04:13:22.390

Reputation: 35 057