Setting a Custom DirectoryIndex Page on Apache2

Typically, when you access a web site, there are pages that I'm going to refer to as "index pages" -- these are typically going to be index.html on the web server. While most webmasters keep this as the default, when handling .html pages like on this web site, others may need to change this setting. For example, if you use WordPress, you will want to set the web server to use index.php instead.

Making this change is fairly simple:

  1. Open either your .htaccess or domain.conf file
  2. If you are not using an .htaccess file, you will need to write lines reading <Directory [dir]> and </Directory>. HTACCESS users can skip this step.
  3. Inside either the <Directory /> lines or .htaccess file, write "DirectoryIndex file.ext". So, for WordPress, you would do "DirectoryIndex index.php".
And it should be set up. This would mean that your web site's visitors would not get an unexpected "Index of [path]" or 403 Forbidden error.
Anton McClure / anton@aperture.nonpaged.com