Directory blocking


#1

How do I make so people can’t just do www.mydomain.com/uploads 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.


#2

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


MacManX.com


#3

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


Options -indexes


#4

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


#5

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.


MacManX.com


#6

.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


#7

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


MacManX.com


#8

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

– Dan