How to install my 404 error page for pages not found?
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.
- An intelligent 404 page
The idea is that the 404 page has a list of links related to the missing page that is requested by the user. This is easily done with keywords tools in Wordpress.
A similar script could extracts the keywords in the requested URL to be adapted for static pages.