Lighttpd Deny Access To Folders / Directories

To deny access to certain folders or directories in Lighttpd, you can use the URL access control feature in Lighttpd. This can be done by using the url.access-deny configuration directive in your Lighttpd configuration file. Here is an example configuration that denies access to the /secret directory:

$HTTP["url"] =~ "^/secret/" {
url.access-deny = ( "" )
}

This configuration directive matches the URL with a regular expression, and if it matches, access to the URL is denied. The regular expression "^/secret/" matches URLs starting with /secret/. In this example, access to the /secret directory is denied for all users by using an empty parenthesis ( "" ).

It’s important to note that this configuration only denies access to the directory, but it won’t prevent the files in the directory from being served if they are requested directly. If you want to prevent the files from being served, you’ll need to remove the files from the directory or modify the file permissions to make them unreadable.

Leave a Comment