How to Set Up a Custom Error Page

Introduction

A custom error page enhances user experience by providing informative messages when an error occurs, such as a 404 Page Not Found or 500 Internal Server Error. Instead of displaying generic error messages, you can design your own error page with branding and helpful navigation links. This guide will walk you through setting up custom error pages for your website.

Step 1: Determine Which Error Pages You Need

Common error pages include:

  • 404 Not Found – When a page does not exist.

  • 403 Forbidden – When access is denied.

  • 500 Internal Server Error – When the server encounters an issue.

  • 503 Service Unavailable – When the server is temporarily down.

Identify which pages you want to customize before proceeding.

Step 2: Create Your Custom Error Page

  1. Open a text editor or an HTML editor (e.g., Notepad++, Visual Studio Code).

  2. Create an HTML file with a descriptive message, such as:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Page Not Found</title>
        <style>
            body { text-align: center; font-family: Arial, sans-serif; }
            h1 { color: red; }
        </style>
    </head>
    <body>
        <h1>Oops! Page Not Found (404)</h1>
        <p>The page you are looking for might have been removed or is temporarily unavailable.</p>
        <a href="/">Return to Homepage</a>
    </body>
    </html>

    HTMLCOPY

  3. Save the file as 404.html, 403.html, or the corresponding error name.

Step 3: Upload Your Error Page to the Server

  1. Open File Manager in cPanel or connect via FTP.

  2. Navigate to the public_html directory.

  3. Upload the custom error page files (e.g., 404.html).

Step 4: Configure the .htaccessFile (For ApacheServers)

  1. Locate the .htaccess file in public_html (create one if it doesn’t exist).

  2. Open it with a text editor and add the following lines:

    ErrorDocument 404 /404.html
    ErrorDocument 403 /403.html
    ErrorDocument 500 /500.html

    ApacheCOPY

  3. Save and upload the updated .htaccess file.

Step 5: Configure Custom Error Pages in cPanel (Alternative Method)

  1. Log into cPanel.

  2. Navigate to Advanced > Error Pages.

  3. Select the domain for which you want to set up error pages.

  4. Click on the error code (e.g., 404), then enter or paste your custom HTML content.

  5. Click Save.

Step 6: Test Your Custom Error Pages

  1. Open a browser and type a non-existent URL (e.g., yourdomain.com/nonexistentpage).

  2. If configured correctly, your custom 404 error page should appear.

  3. Repeat the test for other error pages.

Conclusion

Custom error pages improve user experience by offering helpful guidance when an error occurs. Whether using .htaccess or cPanel’s built-in options, setting up branded and user-friendly error pages helps maintain engagement and professionalism on your website.

Last updated

Was this helpful?