---
title: "Changing index pages"
date: "2014-10-31"
category: "web-content"
slug: "changing-index-pages"
---

## Overview

An index page is the default page the web server displays when a visitor accesses a directory without specifying a filename. For example, visiting `http://example.com/` causes the server to scan the [[where-is-site-content-served-from]] for the first matching file from the default list.

The default index page order of precedence is: `index.html`, `index.php`, `index.shtml`, `index.htm`, `index.cgi`, `index.pl`, and `index.jsp`. The first file found in this list is served as the directory index.

## Changing the Default Index Page

To set a custom index page, add a `DirectoryIndex` directive to your [[htaccess-guide]]. For example, to use `home.html` as the index page:

```
DirectoryIndex home.html
```

With this directive, visiting `http://example.com/` serves the same content as `http://example.com/home.html`.

## Caveats

The `DirectoryIndex` directive applies recursively to all subdirectories. To override it for a specific subdirectory, create a separate `.htaccess` file in that directory with its own `DirectoryIndex` directive.

**Example:**

- `/var/www/html/.htaccess`: `DirectoryIndex home.html`
- `/var/www/html/myapp/.htaccess`: `DirectoryIndex index.html index.php index.shtml index.cgi`

This cascading behavior can lead to a complex hierarchy of `.htaccess` files. For this reason, use `DirectoryIndex` sparingly.
