Free auditStart free
GuideError · HTTP status codes

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.

4 min
read
6
sources
Oct 28, 2026
updated
Scaplet Editorial Team
author
The short answer

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.

  1. Prove that Apache reads your .htaccess
  2. The four patterns that return 404
  3. Verify status codes, then check what Google sees
30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01How it works

Prove that Apache reads your .htaccess

Most .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. 1

    Add a nonsense word

    Put thisisnotadirective on its own line at the top of the .htaccess file and load any page in that folder.

  2. 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 None is in effect for that path.

  3. 3

    Enable overrides for the directory

    In the main config or virtual host, set AllowOverride FileInfo for rewrite rules, or AllowOverride All. On shared hosting you cannot edit this, so ask the host or move the rules into the vhost.

  4. 4

    Confirm the rewrite module is loaded

    apachectl -M | grep rewrite should show rewrite_module. The module must be present before RewriteRule lines do anything.

Virtual host that lets .htaccess rewrite
<Directory "/var/www/example.com/public">
    # FileInfo covers RewriteRule and ErrorDocument in .htaccess
    AllowOverride FileInfo
    Require all granted
</Directory>
02Fix it on your stack

The four patterns that return 404

Front controller with rewrite rules (subfolder app)
# /var/www/htdocs/myapp/.htaccess
RewriteEngine On
RewriteBase "/myapp/"
RewriteCond "%{REQUEST_FILENAME}" !-f
RewriteCond "%{REQUEST_FILENAME}" !-d
RewriteRule "^(.*)$" "index.php" [L]
The same job with one line
# 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
Custom 404 page that still returns 404
# 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
Symptoms and fixes
SymptomCauseFix
Every pretty URL 404s, real files loadFront controller rules never run, or run against the wrong path. In .htaccess, RewriteBase defaults to the directory's physical pathSet RewriteBase "/app/" when the site lives in a subfolder or behind an Alias or symlink
Only the home page worksThe front controller rule lacks the !-f and !-d conditions used in Apache's example, or points at a script that does not existAdd !-f and !-d conditions, or use FallbackResource
/about 404s but /about.html worksNo rule or MultiViews mapping /about to a fileAdd a rewrite rule, or enable Options +MultiViews and read the negotiation caveat below
Custom 404 page shows, but the status is a redirectErrorDocument with a full http:// URL, which Apache turns into a redirectUse a local path in ErrorDocument 404, then verify with curl -I
Strengths
  • FallbackResource is 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 RewriteCond lines
Weaknesses
  • It only routes requests that map to nothing, so it cannot rewrite /old to /new or force a host name
  • Needs AllowOverride Indexes when set in .htaccess, as the directive's Override line states
03Check it

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.

Check real and missing URLs
# 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.log
Questions

Asked 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.

Sources · 6

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • apache.org
  • google.com
  1. 01Apache httpd 2.4: .htaccess fileshttpd.apache.org · checked 2026-11-01
  2. 02Apache httpd 2.4: mod_rewrite and .htaccesshttpd.apache.org · checked 2026-11-01
  3. 03Apache httpd 2.4: mod_dir (FallbackResource)httpd.apache.org · checked 2026-11-01
  4. 04Apache httpd 2.4: core features (ErrorDocument, AllowOverride)httpd.apache.org · checked 2026-11-01
  5. 05Apache httpd 2.4: content negotiation (MultiViews)httpd.apache.org · checked 2026-11-01
  6. 06How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane