Lighttpd Control a Directory Listing With mod_dirlisting
Lighttpd web server will generate a directory listing if a directory is requested and no index-file was found in that directory. mod_dirlisting is one of the modules that is loaded by default and doesn't have to be specified on server.modules to work.
Task: Enable Directory Listings Globally
Open lighttpd configuration file:
# vi /etc/lighttpd/lighttpd.conf
Append / modify
server.dir-listing = "enable"
OR
dir-listing.activate = "enable"
Save and close the file. Restart lighttpd:
# /etc/init.d/lighttpd restart
To disable directory listing, use:
dir-listing.activate = "disable"
Enable directory listing only for a directory
You can also enable or disable listing on selected url / directory combination. For example, display directory listing only for /files/:
$HTTP["url"] =~ "^/files($|/)" { server.dir-listing = "enable" }
OR
$HTTP["url"] =~ "^/files($|/)" { dir-listing.activate = "enable" }
Further readings:
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Lighttpd run php from different host using mod_proxy / mod_fastcgi
- Lighttpd install perl, mysql support in chrooted jail
- Lighttpd / Apache : Run Xcache in Chrooted Jail
- Lighttpd 1.5 fastcgi php mod proxy backend fastcgi configuration howto
- Howto: Lighttpd web server setting up virtual hosting
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: configuration file, directory listing, directory listings, index file, lighttpd, lighttpd disable dir listing, lighttpd enable dir listing, mod_dirlisting, server modules, url directory, url files, web server



Hello.
Another way to avoid the directory listing is creating an index.html with no content in the directory that you don’t want to be listed. Nothing will happen when that url is opened and it is a quite fast method I think.
Maybe this way can be easily “hacked”… I don’t really know.
Bye!!