Enable / Disable Directory Listing using htaccess

by Rekha 2009-12-30 14:53:04

1)To allow a web server to produce a directory listing, whenever you point a directory without index file. Add following line in your .htaccess file.


Options +Indexes
# or #
IndexIgnore *


2)To disable or prevent the directory access add following line in your .htaccess file. If user points the browsers to a directory which does not have index file then in this case 403 error will be

Options -Indexes


3)Change Listing style - You may want to display other details while showing the directory listing. This includes file icons, file size, modification date and more. This can be done by adding fancy style to your htaccess file. Add following snippet in .htaccess file.

IndexOptions +FancyIndexing


4)To remove the fancy directory listing or to display normal directory listing, use -FancyIndex.

IndexOptions -FancyIndexing


5)Ignore files with specific extension - It may happen that you may need to ignore certain files to get displayed in directory listing. This can be achieved using IndexIgnore directive in .htaccess file.Following snippet will not display .zip and .txt file in directory listing.

IndexIgnore *.zip *.txt


6)Modify Index File - It is possible to change the default index file from index.html (index.php, index.jsp …) to any other file. Following line will change the index file to Home.html.

DirectoryIndex Home.html

Tagged in:

981
like
0
dislike
0
mail
flag

You must LOGIN to add comments