Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Web Servers»Apache»Apache 404 Redirect to Homepage

    Apache 404 Redirect to Homepage

    By RahulAugust 12, 20201 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 exists on the server. As per the SEO perspective, its not good to return 404 error code to user even requested file doesn’t exit.

    Advertisement

    To solve this error, you can create a custom error page or redirect user to website home page. This tutorial will help you to redirect user to home page if 404 error occurred on server.

    Setup 404 Redirect to Homepage

    Edit .htaccess file under the document root of your Website hosted via Apache server. Add below content to the end of file.

    For example, you website document root is /var/www/domain.com. The the .htaccess file needs to edit at /var/www/domain.com/.htaccess. Make sure to change domain.com with your actual domain name.

    1
    2
    #### Error Documents
    ErrorDocument 404 https://domain.com/

    Save file and close it.

    Now, access any file to your domain, which doesn’t exist on server. Test if webpage is redirected to the home page instead of showing 404 error page.

    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

    Add A Comment

    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.