buy tb500

How do I change the default index page?

By default, if you request a directory (e.g. http://example.com/ or http://example.com/support/) Apache keeps a list of files it should look for (in order) before it should try and display the contents of the directory. Normally it isn’t allowed to do this, and so will either give a 403 error warning, or, if you are requesting the initial page (such has http://example.com/) then you may see a ‘Test Page’ for Apache and CentOS.

This list of files is set in the master Apache configuration file (httpd.conf – for more information about it, see this article), and looks something like:

DirectoryIndex index.html index.shtml index.cfm index.php index.php3

Therefore, it will look for index.html first. If it cannot find that file, it try and look for index.shtml, and so on. However, if you have (for example) index.htm or default.html, then, as it is not in the list, it will not be called. To change this you will need to add your own DirectoryIndex command within a .htaccess file to extend the list.

Setup

Create a .htaccess file with the following contents (if you want to use index.htm) then upload it to the directory where you want this to work:

DirectoryIndex index.htm

Note that all sub-directories below the directory where you put the .htaccess file will also be affected by this change. Normally it’s placed being placed in the doucment root (httpdocs/) so that it affects all directories on a website.

For more infromation on how .htaccess files work, see this article. Also, if you make a mistake with a .htaccess file, Apache will report a 500 error and your site will be unavailable until either you correct the mistake or delete the file. Only use this if you are sure of what you are going.

Leave a Reply