This article describes how to use the DirectoryIndex directive in an .htaccess file to specify which page is displayed when a visitor requests a directory.
By default on A2 Hosting servers, when visitors go to a URL that requests a directory, such as http://example.com/products, the web server looks for a file in the products directory named index.html. If the index.html file does not exist, the web server looks for index.htm and other similar filenames. If none of these files are found, the web server either lists the files in the current directory (if directory index listings are enabled), or displays a “403 Forbidden” error message (if directory index listings are disabled).
You can use the DirectoryIndex directive in an .htaccess file to specify a custom file or files that the web server looks for when a visitor requests a directory. To enable the DirectoryIndex directive, use a text editor to modify the .htaccess file as follows. Replace filename with the file that you want to display whenever a user requests the directory:
You can also specify multiple filenames, and the web server will search for each file until it finds a match. Consider this example directive:
DirectoryIndex index.php index.html index.htm
In this directive, when a visitor requests the directory name, the web server looks first for an index.php file. If it does not find an index.php file, it looks for an index.html file, and so on until it finds a match or runs out of files to search.
For more information about the DirectoryIndex directive, please visit http://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex.