Kevin Pei
Kevin Pei

Reputation: 5872

Replace default "index of" page with custom page using htaccess

I honestly despise the style of the default "index of" page when there is no index file. I have created my own, but I don't know how to integrate using htaccess so that when there is no index file, it will display my custom "index of" page instead. How can I do this?

Upvotes: 2

Views: 748

Answers (2)

David Wolever
David Wolever

Reputation: 154584

Use the DirectoryIndex directive.

Upvotes: 2

Gerben
Gerben

Reputation: 16825

You could also use options -indexes so you'll get a 404. Then you can create a custom 404 page that does the directory listing.

Another thing you could do is define custom header and footer files. Apache will add these to the beginning and end of the autoindex's html.

Both solutions don't require you to add your script to every folder you want to have a custom index-of, like David's does.

Upvotes: 1

Related Questions