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.
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.
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.
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
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.
Tags: directory index, htaccess, php
This entry was posted on Monday, March 1st, 2010 at 3:07 am and is filed under Programming, Scripts, Web Tricks. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
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!