First of all you need to understand what the purpose of the
404 error is. It appears when the web server does not find the page requested.
Next, if you have a missing page or server failure, then the visitor should see a
custom error page. This way they don't feel lost, like when the web hosting company shows their standard error page.
If you want to have the www version of your website served to the visitor instead of the non www version (or visa versa) then you need a 301 permanent redirect instruction done in your .htaccess file (Apache servers).