A 404 page is a necessity for any professional website. As files are updated and shuffled around, there is no guarantee that search engines will be up to date with your latest changes. By creating a 404 page, you are keeping the user experience constant throughout the entire website, even if they happen to run across a file or page that is missing.
Create HTML/CSS Template
Once you have built your entire website, copy one of your site’s pages and call it error.html. Inside this HTML document, change all of the asset’s (CSS,JS,images,etc) paths to be absolute. This will ensure that your assets will always load, no matter how deep into the directory structure the user goes.
Create the .htaccess File
To those who are unfamiliar with what an .htaccess is, review the following website: http://httpd.apache.org/docs/1.3/howto/htaccess.html
Create a text file called htaccess.txt and add the following lines:
ErrorDocument 404 /error.html Options -Indexes
The first line creates a rule on your web server that routes the user to the error.html page if they have come across a missing page or file.
The second line is responsible for hiding the contents of a directory that does not contain an index or a default file. This prevents users from rummaging through your asset directories
Rename htaccess.txt to .htaccess
We initially created the htaccess file as a .txt, because our computers are able to view and edit these filetypes rather easily. As soon as we rename htaccess.txt to .htaccess, the file now becomes invisible depending on your system’s settings. It is best to wait until the file has been uploaded to the server before you rename it. This prevents you from having to hide/unhide hidden files constantly. Inside your FTP application, make sure you are able to view hidden files. In FileZilla click on “Server/Force showing hidden files“. Now upload the htaccess.txt file and rename it .htaccess.