Create A Custom 404 Error Page on Apache

Channel: Linux
Abstract: create and edit the .htaccess file under the document root of your application and add the following content to the end of the file. #### Error Docume

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.

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.

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

#### Error Documents ErrorDocument 404 /custom_404.html12#### Error DocumentsErrorDocument 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.

Ref From: tecadmin

Related articles