Recommended Free Tools
Apache shows Directory index forbidden by Options directive when a request targets a directory, none of the files named by the effective DirectoryIndex directive exists there, and directory listings are disabled. The safest fix is usually to put the intended entry file in the directory Apache is actually serving, then make its name match the active DirectoryIndex list.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
Enable Options +Indexes only when you deliberately want visitors to browse files in that directory. It changes the response to a generated listing; it does not create or execute a missing application index file and may expose backups, uploads, or private filenames.
As an Amazon Associate I earn from qualifying purchases.
What the error means
Apache’s mod_dir module handles requests that map to directories. When a browser requests a URL such as https://example.test/ or https://example.test/downloads/, Apache resolves that URL to a filesystem directory and then performs an index lookup.
- Apache identifies the active virtual host and its document root (or an alias target).
- It checks the effective
DirectoryIndexlist, such asindex.htmlorindex.html index.php, in that directory. - If one of those resources exists and is accessible, Apache serves it.
- If none exists, Apache can generate a directory listing only when the
Indexesoption is enabled. - When no index exists and
Indexesis disabled, the request ends with HTTP 403 and the log commonly includesAH01276: Cannot serve directoryor the shorter “Directory index forbidden by Options directive” message.
The key distinction is that DirectoryIndex selects an existing resource; it never creates one. The Indexes option controls whether Apache may show a generated listing after the index lookup fails.
Start with the complete error-log entry
Do not begin by editing the first .htaccess file you find. Read the entire error-log line generated at the time of the 403 response. It normally contains a path and a parenthesized list similar to:
AH01276: Cannot serve directory /var/www/site/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
Record three details:
- The filesystem path. This is the directory Apache tried to serve. It may differ from your project folder, especially when aliases, symlinks, containers, or multiple virtual hosts are involved.
- The names in the “No matching DirectoryIndex” list. These are the resources Apache actually tried, not necessarily the values in the configuration file you last edited.
- The active host and request URL. A hostname can select a different virtual host and document root from the one you expected.
Use the timestamp of the request to avoid chasing an old configuration error. If the path in the log is not the directory you intended, fix the mapping first; changing index settings in the wrong project cannot affect the request.
Fastest safe repair: restore the intended index file
For a normal website or application, restore the entry document rather than turning on a listing.
- Locate the directory named in the log. Check the exact spelling and capitalization. On case-sensitive filesystems,
Index.html,index.html, andINDEX.HTMLare different names. - Confirm the application’s entry point. Common examples are
index.html,index.php, or another file supplied by the application. Do not create an empty placeholder unless an empty response is genuinely intended. - Put that file in the served directory. If deployment placed it one level below the configured document root, move it or correct the document-root mapping.
- Check ownership and read permission. Apache’s worker account must be able to traverse the parent directories and read the index file. A correctly named file that cannot be read can lead to a different error, so inspect the next log message if the result changes.
- Request the canonical directory URL. Include the trailing slash, for example
/shop/rather than/shop. Apache normally redirects a directory URL without the slash before evaluating its index.
After the file is in place, refresh the directory URL and inspect the log again. If the response is still 403, the effective configuration or the selected virtual host is probably not the one you edited.
Confirm the active document root and virtual host
Apache maps a URL to a directory through the selected virtual host’s DocumentRoot, aliases, and directory rules. The same path can therefore behave differently for two hostnames or ports.
Check which host answered
Verify the hostname in the browser, reverse proxy, load balancer, or health check. A request sent to an IP address, an alternate name, or HTTP instead of HTTPS may select another virtual host. Review the virtual-host configuration for the matching ServerName and ServerAlias, then note its DocumentRoot.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #2
- Used Book in Good Condition
Compare the configured root with the log path
If the virtual host has DocumentRoot /var/www/site/public, a request for its root should produce a log path under /var/www/site/public/, unless an alias or rewrite changes the mapping. A log path under another release directory, a distribution default such as /var/www/html, or a container mount indicates that the request is reaching a different mapping.
Account for aliases and symbolic links
An Alias can map a URL such as /assets/ to a directory outside the document root. A symbolic link can make the physical directory differ from the project path shown in your deployment notes. Inspect the target and apply the index file and directory rules to the path Apache actually resolves.
Set an explicit DirectoryIndex list
When the filename is correct but Apache is looking for the wrong names, define the intended order explicitly in the server or virtual-host configuration:
<Directory "/var/www/html">
DirectoryIndex index.html index.php
Require all granted
</Directory>
Apache tries the names from left to right and serves the first existing resource it can use. Put the preferred entry point first. For a PHP application, this directive only selects index.php; it does not configure a PHP handler, prove that PHP is installed, or resolve application-level errors.
Free tools Windows power users keep installed
One-click scans. No signup required.
Replacing inherited values
Multiple DirectoryIndex directives can add resources to an inherited list. If a parent configuration supplies unwanted names, reset the list before defining a replacement:
<Directory "/var/www/html">
DirectoryIndex disabled
DirectoryIndex index.php
</Directory>
Use this deliberately. Resetting an inherited list can remove a required fallback for another application if the directory block is broader than intended. Scope the block to the specific document root or subdirectory.
Where the directive is allowed
DirectoryIndex belongs to Apache’s Indexes override class. It can be placed in .htaccess only when the enclosing server or virtual-host configuration permits that class, for example:
<Directory "/var/www/html">
AllowOverride Indexes
</Directory>
A broader applicable override policy can also permit it. With AllowOverride None, Apache ignores per-directory configuration for this purpose (or rejects it, depending on the directive and context), so edit the virtual-host/server configuration or ask the administrator to make the change.
Fixing the problem in .htaccess
If you do not administer the main configuration, a site-level .htaccess file may be appropriate. Place it in the directory whose index behavior you need, or in a parent directory that Apache traverses on the way to it.
DirectoryIndex index.html index.php
Three conditions must all be true:
- The file must be in the directory Apache is serving, or the path must be mapped there.
- The server must allow the
Indexesoverride class (or a broader class that includes it). - No later or more specific configuration must disable or replace the list.
Apache reads .htaccess files hierarchically. A parent file can contain Options -Indexes, a competing DirectoryIndex, or rewrite rules that send the request elsewhere. A child file cannot make an index appear in a different physical directory.
When enabling a directory listing is the right fix
Some directories are intentionally browsable, such as a controlled public download area. In that case, enable listing only for that directory:
<Directory "/var/www/html/downloads">
Options +Indexes
</Directory>
mod_autoindex generates the listing when no configured index resource exists. A corresponding .htaccess setting is possible only if the server permits the Indexes override class:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Options +Indexes
Do not apply Options +Indexes to an entire document root as a quick way to silence the 403. A listing can disclose filenames, old releases, database dumps, editor backups, uploaded documents, and other information that was never meant to be public. It also does not run an application’s missing home file.
| Approach | Result | Best use | Main risk or limitation |
|---|---|---|---|
| Restore or correctly name the application index | Apache serves the intended home document | Websites, frameworks, and application roots | Requires the correct file in the mapped directory |
Set an explicit DirectoryIndex |
Apache tries the desired filenames in a known order | Sites with non-default entry names or multiple fallbacks | Has no effect if the file is absent, unreadable, or the directive is not allowed |
Enable Options +Indexes |
Apache generates a file listing through mod_autoindex |
Deliberate public download or browsing directories | May expose sensitive names and still leaves an application without its entry point |
Inspect inherited and conflicting settings
Apache’s effective behavior is assembled from the global configuration, virtual-host blocks, nested <Directory> sections, aliases, parent .htaccess files, and child .htaccess files. Search all applicable configuration sources for:
Options -Indexes, which disables generated listings.Options +Indexes, which enables them for a scope that may be broader or narrower than expected.DirectoryIndexdirectives that add an unexpected filename.DirectoryIndex disabled, which removes inherited index resources until another list is defined.- A more specific
<Directory>block for the physical path. AllowOverride Noneor an override class that excludesIndexes.
Do not assume that a setting visible in one configuration file is effective for the request. The selected virtual host and the most specific path rules determine what Apache uses. On systems that provide a configuration-dump command, use it to identify loaded virtual hosts and included files; otherwise inspect the distribution’s enabled-sites and conf-enabled directories.
Reload Apache safely after a configuration change
Validate syntax before reloading. The exact command depends on the operating system and service name, but common examples are:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallapachectl configtest
sudo systemctl reload apache2
On systems whose service is named httpd, the equivalent pattern is:
apachectl configtest
sudo systemctl reload httpd
Run the syntax test first and proceed only when it reports a successful configuration. A reload applies configuration to new requests without the full interruption of a stop/start. If your hosting panel or managed service controls Apache, use its documented reload mechanism or request an administrator change instead of editing generated files that will be overwritten.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Verify the fix methodically
- Request the URL with its trailing slash, such as
/downloads/. - Confirm the status is no longer 403 and that the response is the intended index document or intentionally generated listing.
- Check the response content, not only the status code. A custom error page, redirect loop, or application exception can hide the original directory problem.
- Watch the error log while making a fresh request. A new
AH01276line means Apache still found no usable index and still could not list the directory. - If the index is a script, check the language handler and application logs separately.
DirectoryIndexselection does not execute or configure the script runtime.
Troubleshooting branches
| Symptom | Likely cause | What to check next |
|---|---|---|
The log lists index.html, but the file exists in your project |
The request maps to a different document root, alias, virtual host, or symlink target | Compare the log path with the active host’s DocumentRoot and inspect aliases |
You added DirectoryIndex to .htaccess, but nothing changes |
The override class is not allowed, or another configuration overrides it | Check AllowOverride Indexes, parent files, and the effective virtual-host block |
Turning on Options +Indexes produces a listing |
The directive is working and no configured index exists | Decide whether the listing is intentional; otherwise restore the application index |
| The filename differs only by capitalization | The filesystem is case-sensitive | Rename the file or change DirectoryIndex to the exact case |
index.php is selected but the page fails |
PHP handler, permissions, or application code is failing after index selection | Read the runtime and application logs; do not treat DirectoryIndex as PHP configuration |
/folder and /folder/ behave differently |
The directory-slash redirect is being intercepted or tested through a proxy | Test the canonical trailing-slash URL and inspect redirect and rewrite rules |
| A change works briefly, then disappears | A deployment process, hosting panel, or generated configuration replaced the edit | Apply the change in the authoritative template or management interface |
Common mistakes to avoid
Editing the wrong .htaccess file
Apache evaluates the hierarchy leading to the requested directory. A file in the project root may not govern an aliased subdirectory, while a parent file can disable indexes for every child. Use the physical path from the log to determine which files matter.
Using a listing to conceal a missing deployment
A successful listing can make the 403 disappear while leaving the site without its real entry point. Treat it as an intentional content decision, not a generic repair.
Assuming a configured name proves the resource exists
DirectoryIndex index.php only instructs Apache what to try. It does not upload the file, correct a typo, grant filesystem access, or configure an interpreter.
Ignoring capitalization, symlinks, and release paths
Case-sensitive names and deployment symlinks frequently explain why a file that appears present is not present at the path Apache resolved. Verify the actual target, not just the path shown in an editor.
Forgetting the trailing slash
Directory requests are normally canonicalized with a trailing slash before index processing. Test that canonical URL so redirects, relative links, and rewrite rules do not obscure the result.
Security checklist after the 403 is gone
- Keep
Options -Indexesfor application and document-root directories unless browsing is a documented requirement. - Limit
Options +Indexesto the smallest download directory that needs it. - Remove backup files, archives, database exports, and editor swap files from web-accessible paths.
- Use an explicit, minimal
DirectoryIndexlist rather than inheriting unknown names across unrelated applications. - Review the error log after deployment to ensure the request reaches the intended virtual host and path.
- Remember that a 403 caused by a missing index is different from authorization failures; changing access controls can create a separate security problem.
The practical decision
If this is a website or application root, place the intended index file in the directory named by the error, make its exact name appear in the effective DirectoryIndex list, and ensure the active virtual host and override permissions point to that directory. If the directory is intentionally a public file area, enable Options +Indexes only there and review what the generated listing reveals. That distinction fixes the underlying cause without turning a missing entry point into an information-disclosure issue.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




