To prevent access through HTTP for all contents of a directory, simply apply
to that directory. With a .htaccess file, the directive above is all that it need contain. In the server configuration, you'd use a Directory directive to select the directory, first:
Code:
<Directory /path/to/directory>
Deny from all
</Directory>
To affect a particular file, or files with a single extension, you'd use the Files directive:
Code:
<Files filename>
Deny from all
</Files>
<Files *.ext>
Deny from all
</Files>
For multiple extensions, or for filenames that match a particular pattern, use the FilesMatch directive which uses regular expressions:
Code:
<FilesMatch "\.(gif|jpe?g|png)$">
Deny from all
</FilesMatch>
The above would restrict all .gif, .jpg, .jpeg, and .png files.
Again, in the server configuration, the Directory would be used in combination with the Files(Match) directive to be specific to a certain directory. There's also a DirectoryMatch directive that operates similarly to FilesMatch. Remember that a .htaccess file will affect the directory that it's in, plus all descendant directories.
Mike
Bookmarks