Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Web Servers»Apache»Create A Custom 404 Error Page on Apache

    Create A Custom 404 Error Page on Apache

    By RahulApril 19, 20221 Min Read

    Apache Error code 404 means “file not found”. This is the error code when a user requested a web page or file which does not exist on the server. As per the SEO perspective, it’s not good to return a 404 error code to the user even requested file doesn’t exist.

    Advertisement

    Now, You can either configure a custom 404 error page on your server or redirect the website to the home page. In this tutorial, we will help you to create a custom 404 error page for your Apache server.

    Create A Custom 404 Error Page

    First of all, create a 404 file on your server. You can create this file under the document root of your application. For example, I have created a file named custom_404.html under the document root with the following content.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <html>
    <head>
    <title>Error 404</title>
    </head>
    <body>
    <div class="container">
    <h1>404</h1>
    <h2>Page Not Found</h2>
    <p>The Page you are looking for doesn't exist or moved to other location. Go to <a href="">Home Page.</a></p>
    </div>
    </body>
    </html>

    Next, create and edit the .htaccess file under the document root of your application and add the following content to the end of the file.

    1
    2
    #### Error Documents
    ErrorDocument 404 /custom_404.html

    Save the file and close it.

    Now, access any file to your domain, which doesn’t exist on the server. You will see the custom error page instead of the default Apache error message on your web browser.

    404 Apache Error page
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Comparing Apache MPM Worker and Prefork: Which is Right for Your Application

    An Introduction to Apache MPM (Multi-Processing Modules)

    How to Install Apache (httpd) on RHEL & CentOS Stream 9

    View 1 Comment

    1 Comment

    1. Cory on May 21, 2021 8:04 pm

      Thanks Rahul, much appreciated!

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.