How to Troubleshoot an Apache With a 404 Error
1. Check the index.html file in the server's web directory. If a client requests a page from a website hosted on the server, the index.html file for that site needs to be present or a 404 error will result. Multiple websites can be hosted on an Apache server and each need their own index.html file. If the index.html file is not present for the requested website, reload the index.html from a backup or rebuild the file. Attempt to access the resource again. If the page displays, the issue is resolved. If the page doesn't display, proceed to Step 2.
2. Verify the requested resource. Within the website's directory exists all the pages available for viewing. Verify that the specific page requested is present in the directory with the correct name. If the specific page does not exist, reload the page file to the web directory from a backup or rebuild the page. If the file exists, but is misnamed, rename the file to the correct name. Attempt to access the resource. If the page can be displayed, the issue is resolved. If the page still doesn't display proceed to Step 3.
3. Check the server root settings. The server root is the top level directory, which holds the server's log, configuration and error files. If the server root setting is varied from the standard, the server may not be able to find the requested files. For example, if the server root setting is set to '/var/www' a correction will need to be made to the configuration file so that the server can find the requested data. To resolve this issue, access the server's configuration file and add the line 'Document root '/var/www'' above the lines that read 'User www-data' and 'Group www-data.' Attempt to access the page again. If the page displays, the issue is resolved. If the page doesn't display, proceed to Step 4.
4. View the server's error log file. The error log file is where the Apache server will log any errors it encounters. The error log is located in the server root directory and can be accessed by typing into the terminal 'logs/yourwebsite.error' where 'yourwebsite' is the site's name. Examine all the errors to determine a common characteristic or variable that is causing the server to report 404 errors.