Put the following in an .htaccess file in the document root or the top most directory in which you want directory indexing disabled:
Options -IndexesThus when one visits http://example.com/images/ and there is no index.* file in ~/example.com/images, they will get a forbidden message.
Or of course just put an index.* file in each and every directory.
Just update the regular expression to check if the end of the URL is a slash in addition to image file extensions. Beware this won’t work in the document root, as the slash is stripped, ie
http://example.com/ = “” (null string)
http://example.com/images/ = “images/”
Perl / MySQL / HTML+CSS