.htaccess Tutorial - Directory Listing

When a web browser is pointed to a directory on your web site which does not have an index.html file in it, the files in that directory can be listed on a web page.

1. Enable/Disable Directory Listing

To have the web server produce a list of files for such directories, use this line,

Options +Indexes  

To have an error (403) returned instead, use this line.

Options -Indexes 
 

2. Listing Style

You can list file in  basic list style or fancy list style. A ‘fancy’ list including icons, file size, modification date and more. Following line is used for ‘fancy’ list style in the .htaccess file,

IndexOptions +FancyIndexing  

Use following line if you prefer a basic file list.

IndexOptions -FancyIndexing  

3. Ignore Files

If you don’t want the web server to list files with exention such as *.txt,*.jpg. Add this line to your .htaccess,

IndexIgnore *.txt *.jpg  

4. Modify Index File

To change the default index file, use this line

DirectoryIndex home.html  
 

Leave a Reply

You must be logged in to post a comment.