How to install my 404 error page for pages not found?

How to access attempts to a nonexistent page redirects the user to an error page?

When the server does not find the page requested by the browser, it returns an error code 404.
We must ensure that the user is not confronted with an error message for better ergonomics. To do this, we create a special page that will be displayed instead of the page not found.

It remains to redirect the visitor to this page ... To do this under Apache we do use the .htaccess file that is created with a text editor, or edited if it already exists.
Note that Wordpress and other CMS have error redirection already taken into account by the system.

Create or fill a .htaccess file with the following content:

RewriteEngine on 
ErrorDocument 404 /error.html 

This file should be at the root of the site, often into the subdirectory "www".

You can download the archive with a ready to use 404 file.

The redirect can move to a 404 page designed for this purpose to encourage the correct link, or just to the home page of the site.
The domain name must not be included in the URL because it impedes search engines. In effect this replaces the 404 code by a 200 code that is for a normal load.
Google will refuse your sitemap if a full URL with domain name is used to redirect errors.

See also...