TECH / Серверы и сайты 2 min read

Apache Error: Directory index forbidden by Options directive – Cause and Fix

NEMCD Author
Published Jul 24, 2010 · 2 min

Seeing Directory index forbidden by Options directive pop up in Apache’s error.log – accompanied by a 403 Forbidden page in the browser – does not usually mean Apache is broken. It simply means someone requested a directory URL that has no default index file, while folder browsing is turned off.

Apache web server logo – fixing Directory index forbidden error

Most of the time, blocking directory listings is good security behavior. Here are three clean ways to resolve the log error depending on what the folder is supposed to serve.

1. Drop an Empty Index File into the Directory (Safest Fix)

Check the exact folder path logged by Apache (for example, /var/www/site/uploads/). If visitors should not see a list of files inside that folder, simply create an empty index.html or index.php:

touch /var/www/site/uploads/index.html

Direct hits to that directory URL will now return an empty 200 OK response instead of filling your error log with 403 warnings.

2. Check Your DirectoryIndex Setting

If your directory already contains index.php or main.html yet Apache still complains, make sure that filename is listed in DirectoryIndex inside .htaccess or your VirtualHost config:

DirectoryIndex index.php index.html index.htm

3. Enable Directory Listing (Only for Public File Downloads)

If the folder is intentionally a public download repository and you want Apache to render a browsable file list, add this directive to that directory’s .htaccess:

Options +Indexes

Security reminder: never enable Options +Indexes globally across a website – doing so exposes internal folders, uploads, and stray backup archives to anyone browsing your URLs. For normal websites, stick to a proper DirectoryIndex or a blank index.html.

In almost every case, one of the first two fixes cleans up your Apache error log immediately.

Related posts:

Leave a Comment