[SOLVED] Error on Apache: No matching DirectoryIndex
What is an Apache Error?
An Apache error is a message generated by the Apache Web Server software and is usually a result of a coding issue or server misconfiguration. Apache errors may include Internal Server Error or 403 Forbidden messages. They can range from minor, easily fixed errors to more serious ones that may require support from a system administrator. Therefore, understanding the causes of Apache errors helps take the necessary steps to resolve the issue.
This article walks through solving the error: No matching DirectoryIndex (index.html) on CentOS 6 and 7 servers, logged in as root.
General Reason for Apache Error
This error may occur when attempting to access applications that have an index.php file (or another index file), but not an index.html or other specified directory index file. For example, phpMyAdmin includes an index.php file upon installation, but not an index.html file.
Default Apache Configuration
By default, Apache is configured with the following.
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
This configuration means that Apache will only look for directory index files that are named index.html. So, when attempting to access phpMyAdmin, Apache throws the following error.
[autoindex:error] [pid 20115] [client 10.30.6.80:50800] AH01276: Cannot serve directory /usr/share/phpMyAdmin/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
In this case, we want to add index.php to the DirectoryIndex directive. To do this, access the file from the text editor of your choice. This tutorial uses Vim.
vim /etc/httpd/conf/httpd.conf
DirectoryIndex File Changes
Locate the following configuration information within the configuration file.
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Make the following change to the file to add index.php to the directive.
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Save and Exit the File
Save and exit the file once the appropriate changes are made. For Vim, exit and save the file with the :wq command.
Restart Apache
Restart Apache to implement the changes.
systemctl restart httpd
Wrapping Up
Solving the No matching DirectoryIndex Apache error is straightforward with the proper knowledge and understanding of the error's underlying cause. Following this tutorial ensures the error is rectified easily.
Liquid Web offers managed hosting options to fit small to medium-sized businesses and enterprise workloads. Contact our sales team for a consultation on what best suits your business.
Related Articles:

About the Author: Justin Palmer
Justin Palmer is a professional application developer with Liquid Web
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
Best authentication practices for email senders
Read Article2024 cPanel and Plesk pricing breakdown
Read ArticleCentOS Linux 7 EOL — everything you need to know
Read ArticleHow to install Node.js on Linux (AlmaLinux)
Read ArticleUpgrading or installing PHP on Ubuntu — PHP 7.2 and Ubuntu 22.04
Read Article