Directory blocking

How do I make so people can’t just do and view my uploads directory (and my others)? I still want my files to be able to be hotlinked, just not my directory. I know a lot of sites say like, the user does not allowed directory contents to be listed.

Put an index.html (or index.php) file in the directory which either redirects to your main page or says something like “Get Out!”.

You want to put a .htaccess file in the directory with the contents between the ‘—’

Options -indexes

Is .htaccess any better than putting a blank index.html file?

Well, if you do the .htaccess wrong, you have the possibility of making that directory inaccessible. But that’s about it. Also, you’ll want to put something in the index file, either “Get Out!” or a redirect. Some browsers tend to ignore blank index files.

.htaccess would propage to subdirectories.

If you had ~/main/subdir/subdir2, you only need to put .htaccess in ~/main and no indexes would be generated for ~/main/, ~/main/subdir and ~/main/subdir/subdir2/

Otherwise you have to have ~/main/index.html, ~/main/subdir/index.html, and ~/main/subdir/subdir2/index.html which is 3 separate files.

:cool: Perl / MySQL / HTML+CSS

But then you’d just copy it three times, no big fuss. But this is all very debatable and hinges on personal preference.

If you have dozens or hundreds of subdirectories, you might find the .htaccess method more convenient.

– Dan