Jamie Jamie - 3 months ago 37
Apache Configuration Question

Preventing directory listing by redirecting?

I want to use

to prevent directory listing.

I've got pages within /location/ but I don't have an index file. So I want to redirect to /location/about.php for example.

Is there a way to do this, without creating an index.html and redirecting requests to that?

Thanks for the help!

Joe Joe

If you're asking for a file in place of 'index.html', see "DirectoryIndex" to tell it what files to use in place of 'index.html':

DirectoryIndex about.php index.html
Options –Indexes

... if you're trying to redirect all directories to a single page, then I'd cheat and do the following, which will mostly do what you're asking for:

Options +Indexes
IndexOptions +SuppressHTMLPreamble
IndexIgnore *
HeaderName /includes/header.html
ReadmeName /includes/readme.html

... and set /includes/header.html with whatever message you want (or containing a meta-redirect), and /includes/readme.html to be blank.