[SOLVED] Error on Apache: No matching DirectoryIndex

Posted on by Justin Palmer | Updated:
Reading Time: 2 minutes

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.

[SOLVED] Apache Error: No matching DirectoryIndex

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.

Avatar for Justin Palmer

About the Author: Justin Palmer

Justin Palmer is a professional application developer with Liquid Web

Latest Articles

Controlling PHP settings with a custom php.ini file

Read Article

How to install Puppet Server on Linux (AlmaLinux)

Read Article

Email security best practices for using SPF, DKIM, and DMARC

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article