Search Our Database

How to change the default file for your website (Apache)

Last updated on |

Introduction

This guide is intended for website administrators and developers who want to change the default landing page of their website hosted on an Apache server. By default, when visitors access your domain, Apache looks for files like index.html or index.php to display as the home page. However, you may want to set a different file as the default. This guide explains how to modify the .htaccess file to define a new default page for your website. The steps are applicable to websites hosted on an Apache web server.

 

Prerequisites

  • Access to your web hosting account
  • A working website hosted on an Apache server
  • Basic knowledge of .htaccess and file editing

 

Step-by-Step Guide

1. Navigate to your website’s root directory: The root directory is usually called public_html or may be a custom directory depending on your hosting setup. You can access it through FTP, your web hosting file manager, or SSH.

2. Check for an existing .htaccess file: Look for a file named .htaccess in the public_html directory.

  • If the file is not present, create a new one:
    • Right-click in the directory and select Create New File.
    • Name the file .htaccess.

3. Open the .htaccess file using a plain text editor. If you ssh in the server, you can edit the file using the command below:

sudo vi .htaccess

4. Add the following line to the file:

DirectoryIndex default.html

Replace default.html with the name of the file you want to set as the default. For example, if your default file is named homepage.html, the line should be:

DirectoryIndex homepage.html

5. Save the .htaccess file after making your changes. If you use vi to edit the file, you can save and exit by using:

:wq

 

Conclusion

By following these steps, you can easily change the default file that loads when users visit your website. This allows you to customize the experience for your visitors without altering other files. If you encounter any issues or need additional assistance, please contact our support team at support@ipserverone.com.