Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Web Servers»Apache»Apache 404 Redirect to Homepage

    Apache 404 Redirect to Homepage

    RahulBy RahulJune 12, 20201 Min ReadUpdated:August 12, 2020

    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.

    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
    Previous ArticleHow to Install Zoom on Ubuntu 18.04
    Next Article Create A Custom 404 Error Page on Apache

    Related Posts

    How To Install Apache Solr 9.0 on Fedora 36/35

    Updated:May 26, 20223 Mins Read

    How to Install Apache ActiveMQ on Ubuntu 22.04

    3 Mins Read

    How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04

    Updated:June 28, 20225 Mins Read

    How To Disable HTTP Methods in Apache

    Updated:December 31, 20212 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    Common Apache Commands on Ubuntu & Debian

    4 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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