Deny access to files

Denying access to specific file extensions

The following code forces any file ending in .inc to throw a 404 Forbidden error when visited:

<Files ~ "\.inc$">
Order Allow,Deny
Deny from All
</Files>

Denying access to "hidden" files

File names beginning with a dot are considered "hidden" by UNIX. Usually, you don't want to serve them to visitors.

DreamHost already disallows retrieving '.htaccess' and '.htpasswd', but you can recursively deny all access to all hidden files by placing the following into a top-level .htaccess:

RedirectMatch 403 /\..*$

Deny access to folders

Denying access to a directory listing

If you don't have an index file in your directory, all of your files are listed in a directory list for anyone to view. The following code forces this directory listing to throw a 404 Forbidden error instead when visited:

Options -Indexes

Denying access during a specific hour of the day

If you wish to block access to files in a directory during a specific time of day, then you can do so by adding the following code to an .htaccess file: