.htaccess template for custom directory views
Here is an .htaccess template for displaying a customized directory with file view enabled, such that all files except for those indicated are displayed as a list.
As explained in the original article at Perishable Press, the following .htaccess code can be used to customize any directory to display files as a list.
# Custom Directory Views # ENABLE DIRECTORY Options +Indexes # SET INDEX OPTIONS IndexOptions IgnoreCase FancyIndexing FoldersFirst SuppressHTMLPreamble # IGNORE THESE FILES IndexIgnore .htaccess .ftpquota favicon.ico _001.gif _002.gif _003.gif _00a.html _00b.html _000.css cgi-bin # SET DISPLAY ORDER IndexOrderDefault Descending Name # SPECIFY HEADER FILE HeaderName _00a.html # SPECIFY FOOTER FILE ReadmeName _00b.html # FOLDER DESCRIPTIONS AddDescription "<span class='description'>Private Directory</span>" transfer # SPECIFY CUSTOM ICONS AddIcon _001.gif .txt .pdf .zip .jpg .jpeg .jpe .JPG .png .gif .mp3 .rar .mpg .indd .psd .tar .tif .html .htm .css .doc .log .js .ico, .eml AddIcon _002.gif ^^DIRECTORY^^ AddIcon _003.gif *.
You can learn more about each of these directives or download the complete set of template files, upload to your own server, and see for yourself how they work. I like to use this template when setting up custom directories for SFTP transfers for clients. Customizing the plain old directory view can add a nice touch.
The following ZIP file contains various files that are used to customize the directory, including icons, HTML templates, a CSS file, a favicon, and an .htaccess file. Note that the .htaccess file is not displayed by default on most machines.
Download the Custom Directory Views Template
To implement the custom template, unzip and upload the entire directory to your server. Then access the directory via your browser to check it out. A couple of notes:
- The directory included in the ZIP file is named “
FTP”. Feel free to change that to whatever works for you.
- As-is, there are no displayed files in the directory. To get a much better idea of how it looks, upload a fistful of image, music, or video files and refresh the page.
That’s all folks, enjoy!