Symptoms
When opening a web page, you encounter a 404 page.
Description
A 404 error means that the web server was unable to locate the requested file. This could be caused by several reasons.
- The file doesn't exist at the specified location.
- The .htaccess file contains incorrect rewrite rules.
- The web server cannot read the .htaccess file.
Workaround
- If the server cannot find the file at the specified location, the file was deleted, uploaded to the wrong location, or there is a typo in the URL or file name.
Please note that Linux servers are case-sensitive. This means that if the file name on the server is MyPage.php, browsing to mypage.php will give a 404 error. - If a .htaccess rewrite rule is causing the 404 error, you will have to correct or remove the rule. Renaming the .htaccess file, then reloading the page is a quick way to determine if a rewrite rule is the problem.
mv -v /home/username/public_html/.htaccess{,.bak}
- If the .htaccess file cannot be read by the web server, /var/log/apache2/error_log will have entries similar to the following.
Failed to open [/home/username/public_html/.htaccess]: Permission denied
The web server will be unable to read the .htaccess file if the .htaccess file or a parent folder has incorrect permissions or ownership. The following article provides the correct permissions and ownership for various web server configurations.
What are the default file permissions for public_html?