The following error may appear when attempting to access a directory-based application (like phpMyAdmin) on an Apache server:
No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
When Apache cannot locate the correct default index file in the requested directory, this error is generated.
What Causes This Error?
Apache uses the DirectoryIndex directive to decide which file to load automatically when a directory is accessed.
By default, Apache often checks only for:
- index.html
If your application contains:
- index.php
But Apache is not configured to recognise it, the server cannot load the directory and throws this error.
This is common with applications like phpMyAdmin, PHP-based admin panels, and custom PHP applications.
How to Fix the “No Matching DirectoryIndex” Error
Follow the steps below to allow Apache to load index.php as a valid directory index file.
- Open the Apache Configuration File
vi /etc/httpd/conf/httpd.conf
- Locate the DirectoryIndex Directive
Find the following line:DirectoryIndex index.html
- Add index.php to the Directive
Update it to:DirectoryIndex index.html index.php
- Save and Exit the File
Press::wq
- Restart Apache
Apply the changes by restarting Apache:systemctl restart httpd
Verification
After restarting Apache:
- Reload the application URL in your browser.
- The directory should now load correctly without showing the error.
By adding index.php to the DirectoryIndex directive, Apache can correctly serve PHP-based applications. This resolves the “No Matching DirectoryIndex” error and prevents access issues for directory-based applications.
If the issue persists, please don’t hesitate to contact our support team for further assistance. Our experts are available 24/7.
Looking to customize your Apache settings further? Check out our guide on How to Modify the Apache port in WHM.