WordPress Code Snippets

A fresh mix of code snippets and tutorials

.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.

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!

Learn more

.htaccess made easy

Show Support

Like our new Facebook Page to show support!