Posted by : Chris London in (Programming, Scripts, Web Tricks)
Simple Custom Directory Index v1.0
Tagged Under : directory index, htaccess, php
I made this for my wife cause she had thousands of pictures she wanted to share with a client of hers. So instead of mailing a CD or using a service like flickr I had her use an FTP client to upload the files to her website in a subdirectory and then I added two files to the parent directory of her files (not the root directory of her site) and it gave her client a simple interface to browse through folders and see thumbnails of all the images in there along with any documents.
How to use:
First you need to download the following zip file and extract them to your computer.
After you have extracted the files upload them via FTP or what ever way you prefer to the lowest directory you want visible. You DON’T need to upload the file to every folder. Just the lowest one and it will work for all of the directories in it for an unlimited number of subdirectories.
Warning
Do not place this in your root directory or any directory where you want the directory to show the index file. You need to make a separate subdirectory for the files you want visible.
Explanation of the .htaccess file:
I felt like it would be fun to explain to you how the .htaccess file of this solution works. Here is the code in full:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule (.*) kw_directory.php [L]
The first line RewriteEngine on is just telling the server to use the rewrite engine.
The second line RewriteCond %{REQUEST_FILENAME} !-f is saying that if the file doesn’t exist.
The third line RewriteCond %{REQUEST_FILENAME} -d is checking if it’s a directory.
The last line is saying that if it’s NOT a file and it IS a directory then use kw_directory.php
Future plans:
This is a very basic solution and not very pretty. If there is enough interest I can make a much better looking solution. Post comments if you’re interested.

Do you have an example of this?
Unfortunately all of the places we know of that are using this are private and not for public view. If anyone is using this and wants to let us use their site as an example please post here. Thanks!