Joe
Joe

Reputation: 8292

add an index file or an .htaccess file for each directory?

Ok so my current sites is on the .htaccess method to block user access to the directory e.g. http://www.example/_directory/ via Options All -Indexes

Question should I stick with that or is putting an index file e.g. index.php in every directory better? I'm thinking of an index.php that will redirect to the homepage rather than giving users an error 403 page.

Opinions?

Upvotes: 0

Views: 375

Answers (2)

Siraj Khan
Siraj Khan

Reputation: 2348

If you're on a Unix/Linux server, you don't need to have blank index files at all in your directories. Just create a .htaccess file and put the following code in it:

Code:

Options -Indexes

When anyone tries to access the contents of a directory that doesn't have an index file, they'll get a 403 error.

Ref : http://wildlifedamage.unl.edu/manual/mod/core.html#options

Upvotes: 0

StephenKing
StephenKing

Reputation: 37630

It would be clever to build your web site in a way that these subdirectories also have content (e.g. about/ also shows some information, when about/history/ and about/our-company/).

If the directories contain only files, it's IMHO totally fine to just have a 403.

Answers to your questions might be very biased.

Upvotes: 2

Related Questions