Lighttpd Control a Directory Listing With mod_dirlisting

by Vivek Gite · 2 comments

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:

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 2 comments… read them below or add one }

1 yermet 03.13.08 at 6:59 pm

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

2 Bradford 04.19.09 at 7:20 am

I didn’t like the idea of all my wordpress directories free for browsing, so I tried the global disable. It didn’t work, but it does work when I specify it in each of the websites I’ve defined in my lighttpd.conf file.

$HTTP["url"] == “website” { dir-listing.activate = “disable” }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: