404 Not Found caused by .htaccess
Pretty URLs return 404 on Apache? Check AllowOverride, RewriteBase, FallbackResource and ErrorDocument, with a test that proves .htaccess is read.
A 404 from Apache that appears after you add rewrite rules usually means the .htaccess file is not being read, or its rules map the request to a path that does not exist. The default AllowOverride None makes Apache ignore .htaccess completely. Prove the file loads, then fix RewriteBase, or replace the rewrite block with FallbackResource.
Where does your site stand?
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.
- Free audit in 60 seconds
- Fixes drafted for your review
- ChatGPT, Perplexity, Gemini and AI Overviews tracked
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.
- Re-check after big site changes
- Keep this page for reference
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.
- Follow the steps below
- Top-traffic pages first
- Check again in a month
Prove that Apache reads your .htaccess
.htaccess 404s are not a rule problem. Apache's own .htaccess guide says the default of AllowOverride is None, which "means .htaccess files are completely ignored unless you explicitly enable them for a directory". Its troubleshooting advice is to put a nonsense word in the file and reload the page.- 1
Add a nonsense word
Put
thisisnotadirectiveon its own line at the top of the.htaccessfile and load any page in that folder. - 2
Read the result
If you get a 500 Internal Server Error, Apache is reading the file, so remove the line and look at your rules. If nothing changes,
AllowOverride Noneis in effect for that path. - 3
Enable overrides for the directory
In the main config or virtual host, set
AllowOverride FileInfofor rewrite rules, orAllowOverride All. On shared hosting you cannot edit this, so ask the host or move the rules into the vhost. - 4
Confirm the rewrite module is loaded
apachectl -M | grep rewriteshould showrewrite_module. The module must be present beforeRewriteRulelines do anything.
<Directory "/var/www/example.com/public">
# FileInfo covers RewriteRule and ErrorDocument in .htaccess
AllowOverride FileInfo
Require all granted
</Directory>The four patterns that return 404
# /var/www/htdocs/myapp/.htaccess
RewriteEngine On
RewriteBase "/myapp/"
RewriteCond "%{REQUEST_FILENAME}" !-f
RewriteCond "%{REQUEST_FILENAME}" !-d
RewriteRule "^(.*)$" "index.php" [L]# Existing files and scripts are served normally; everything else goes to index.php
FallbackResource /index.php
# In a sub-URI, give the full local URL path
# FallbackResource /blog/index.php# Local path: keeps the 404 status
ErrorDocument 404 /errors/not-found.html
# Do not do this: a full URL makes Apache send a redirect
# ErrorDocument 404 https://example.com/errors/not-found.html| Symptom | Cause | Fix |
|---|---|---|
| Every pretty URL 404s, real files load | Front controller rules never run, or run against the wrong path. In .htaccess, RewriteBase defaults to the directory's physical path | Set RewriteBase "/app/" when the site lives in a subfolder or behind an Alias or symlink |
| Only the home page works | The front controller rule lacks the !-f and !-d conditions used in Apache's example, or points at a script that does not exist | Add !-f and !-d conditions, or use FallbackResource |
/about 404s but /about.html works | No rule or MultiViews mapping /about to a file | Add a rewrite rule, or enable Options +MultiViews and read the negotiation caveat below |
| Custom 404 page shows, but the status is a redirect | ErrorDocument with a full http:// URL, which Apache turns into a redirect | Use a local path in ErrorDocument 404, then verify with curl -I |
FallbackResourceis one line, and Apache's docs call it a simpler and more efficient alternative to mod_rewrite for this job- Existing files, images and CSS are served without extra
RewriteCondlines
- It only routes requests that map to nothing, so it cannot rewrite
/oldto/newor force a host name - Needs
AllowOverride Indexeswhen set in.htaccess, as the directive's Override line states
Verify status codes, then check what Google sees
The ErrorDocument docs warn that a remote URL makes the client receive a redirect status instead of the original error, which "can confuse web robots and other clients which try to determine if a URL is valid using the status code". Google's crawling docs add that a 2xx page whose content is an empty page or an error message can show in Search Console as a soft 404, while real 404 URLs are treated as non-existent and the crawl rate for them gradually decreases. So a custom 404 page must send 404. See 404 Not Found and redirect to 404 for the audit side.
# A real route should be 200
curl -sSI https://example.com/about | head -n 1
# A URL that does not exist should be 404, not 200 or 302
curl -sSI https://example.com/this-page-does-not-exist | head -n 1
# Watch Apache's decision in the log (path varies by distro)
tail -f /var/log/apache2/error.logAsked a lot.
4 questions people ask next, answered from the sources on this page.
01Why is my .htaccess file ignored?
The most common reason is AllowOverride None, which is Apache's default and makes .htaccess files completely ignored. Enable AllowOverride FileInfo or All for the directory, and test with a deliberately invalid directive: a 500 error proves the file is read.
02How do I set a custom 404 page in .htaccess?
Add ErrorDocument 404 /path/to/page.html with a local path. A full http URL makes Apache send a redirect, so the client no longer sees 404.
03What is RewriteBase for?
In .htaccess, mod_rewrite must turn a relative result back into a URL path. By default RewriteBase is the file's physical directory path, so set it to the URL path when the site sits in a subfolder, behind an Alias or via a symlink.
04FallbackResource or RewriteRule for a front controller?
Use FallbackResource when you only need unmatched requests to go to one script. Use RewriteRule when you need to change URLs, redirect, or match patterns.
Every fact, linked and dated.
apache.org
google.com
- 01Apache httpd 2.4: .htaccess fileshttpd.apache.org · checked 2026-11-01
- 02Apache httpd 2.4: mod_rewrite and .htaccesshttpd.apache.org · checked 2026-11-01
- 03Apache httpd 2.4: mod_dir (FallbackResource)httpd.apache.org · checked 2026-11-01
- 04Apache httpd 2.4: core features (ErrorDocument, AllowOverride)httpd.apache.org · checked 2026-11-01
- 05Apache httpd 2.4: content negotiation (MultiViews)httpd.apache.org · checked 2026-11-01
- 06How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Tools point. Agencies advise. This one ships.
Run the free audit, then approve the fixes. Every change can be undone.
- 46 fixes shipped without a ticket Brightpipe
- 0→7 ChatGPT citations in six weeks Paylane