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.
#### 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.