How to change the default index page

When a client requests a directory on your account a default page is displayed; that's usually some index page such as index.php or index.html. You can set and change which page is to be displayed by default with the DirectoryIndex directive. You just need to have an .htaccess file in the same directory and put the directive followed by the file to be opened when a client requests that directory.

For example, when a client opens your root URL address (e.g. with their browser, the public_html directory on your hosting account is requested (that's the root web-accessible directory). Let's assume that by default an index.php page is displayed in this case, but you want another page called new_page.html to be shown when someone visits

To do this open the .htaccess file that's in the public_html folder on your account and put the following directive on a new line:

DirectoryIndex new_page.html

Of course, with this example the new_page.html file has to be located in the public_html folder too.

If there's no .htaccess file in that directory, you can create one from the Files section of the Pixie control panel. For more information on this check out the article on creating and editing .htaccess files.

If needed you can list several files after the directive. The first one that's present in the directory will be displayed. For example:

DirectoryIndex new_page.html index.php

will first look for the file new_page.html and if there's no such file in the requested directory, it will look for index.php.

Of course, you can use this directive with any subfolder of public_html, not just for the root public_html folder. You just need to put the directive in an .htaccess file that's located in the particular folder.

Was this answer helpful?

 Print this Article

Also Read