.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 the below line in your .htaccess.
To have an error (403) returned instead, use this line.
2. Listing Style
Either a basic list of files can be shown, or a 'fancy' list
including icons, file size, modification date and more.
IndexOptions +FancyIndexing
|
|
Add this to your .htaccess file to use the 'fancy' style.
IndexOptions -FancyIndexing
|
|
Use the above line if you prefer a more basic file list.
3. Ignore Files
Let's say you have a directory with .jpg, .gif and .png image files.
You only want the .png files to show in the directory listings. Add this line to your .htaccess.
The web server now ignores the .gif and .jpg files.
4. Modify Index File
Maybe you don't want a list of the files, you want
a specific file to be shown instead. You could upload
an index.html file in this directory. There is another way.
DirectoryIndex myfile.html
|
|
Instead of listing the files, web page myfile.html will now be shown
for this directory and its subdirectories.