In order to setup custom 404 page, and prevent user from viewing default error page, you can use ErrorDocument 404 in htaccess. Just copy/paste following snippet into your .htaccess file:
ErrorDocument 404 /pages/errorDocument/error404.php
More about ErrorDocument directive
ErrorDocument directive doesn’t have to be used only for errors 404, and it can do couple of things except from redirecting your visitor. Using ErrorDocument directive, you can redirect users to another website, as well as print custom message to the user.
Example of ErrorDocument syntax:
ErrorDocument error-code some-error-document-file
Here is a snippet with ErrorDocument examples:
1 2 3
ErrorDocument 500 http://example.com/ ErrorDocument 404 /pages/errorDocument/error404.php ErrorDocument 403 "You are forbidden to access this page. How many times should I tell you?"