File is not under the DocumentRoot
- Where to look
- The
DocumentRootof the matching virtual host - Fix
- Move the file, or set
DocumentRootor anAliasto the right directory
Apache returns 404 Not Found when the URL does not map to a file. Check DocumentRoot, Alias, .htaccess rewrites and AllowOverride, then fix the path or rule.
A 404 Not Found from Apache means httpd could not map the URL to a file or handler. Common causes are a file missing under the DocumentRoot, rewrite rules in .htaccess that are not being read because AllowOverride is None, or a wrong Alias. Read the error log, compare the URL to the file path, then fix the mapping.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
By default, httpd takes the URL path of the request and adds it to the end of the DocumentRoot. With a DocumentRoot of /var/www/html, a request for /fish/guppies.html is served from /var/www/html/fish/guppies.html, as the Apache URL-mapping guide describes. Directives like Alias, RewriteRule and ProxyPass change that. If nothing maps to a file or a handler, Apache returns 404. The general meaning of the code is on the 404 Not Found page.
The Apache guide names two common causes of "File Not Found" errors: documents moved from one location to another, and mistyped URLs, whether in the browser or in HTML links. For moved documents it advises URL redirection, so that old bookmarks and links keep working.
DocumentRoot of the matching virtual hostDocumentRoot or an Alias to the right directoryServerName and ServerAlias of each host.htaccess rules ignoredAllowOverride for the directoryAll or to the groups you need, such as FileInfo for rewritesRewriteRule and RewriteCond linesmod_speling, which compares filenames without respect to case (the docs warn it adds load when used for more than occasional corrections)Redirect or RewriteRule from the old URL to the new oneThe AllowOverride row catches many WordPress and framework sites. The Apache docs say that when AllowOverride is None (its default) and AllowOverrideList is None, .htaccess files are completely ignored, and the server will not even try to read them. The rules in .htaccess never run, so a site that relies on them for clean URLs can return 404 for every route that is not a real file.
<Directory "/var/www/html">
AllowOverride FileInfo
</Directory>For a front controller, one line is enough: FallbackResource hands any URL that maps to no file or handler to the script you name, and existing files are served normally. Its default is disabled, which returns 404. It needs AllowOverride Indexes in .htaccess. Earlier httpd versions needed mod_rewrite with -f (exists and is a regular file) and -d (is a directory) tests for the same effect.
FallbackResource /index.phpTo show visitors something useful, set ErrorDocument 404 /errors/not-found.html. The directive can point at a local path, an external URL or a text message. Use a local path. Apache's docs warn that a remote URL makes it send a redirect, so the client does not receive the original error status code, which can confuse robots that check status codes.
Run curl -sI -H 'Host: example.com' http://SERVER-IP/path to see which virtual host answers and with what status.
The ErrorLog directive sets its location. Raise LogLevel for mod_rewrite (for example LogLevel alert rewrite:trace3) to watch each rule apply, as the module's docs describe, and lower it again afterward.
Join the DocumentRoot and the URL path and look for that file. Check the case of every segment.
An Alias or ScriptAlias changes where a URL prefix is served from. Make sure its target path exists.
Reload Apache after config changes and repeat the same request.
AllowOverride or a lost .htaccess can turn many working URLs into 404s at once, so compare Search Console after the deploy. See 4xx errors for the audit steps. The nginx variant covers the same error on the other common server.4 questions people ask next, answered from the sources on this page.
Read ErrorLog, then compare the URL with the file path under the DocumentRoot. Check the virtual host, any Alias, and whether .htaccess rules are read. Then fix the path or rule, reload Apache and retest.
When AllowOverride is None, Apache completely ignores .htaccess files and does not read them. Set AllowOverride in the matching <Directory> block to All or to the directive groups you need.
Use ErrorDocument 404 /path/to/page.html. Use a local path. A full external URL makes Apache send a redirect, so clients do not receive the 404 status. The directive works in server config, virtual host, directory and .htaccess.
Check the case of the filename, the virtual host that answers, and whether an Alias or rewrite rule points elsewhere. A different host or a rewrite that targets a missing file is more common than a missing upload.
Run the free audit, then approve the fixes. Every change can be undone.