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

Canonical: https://scaplet.com/errors/http/404/htaccess

Guide Error · HTTP status codes

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

404 4xx · Client error

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](#prove-that-apache-reads-your-htaccess)
2. [The four patterns that return 404](#the-four-patterns-that-return-404)
3. [Verify status codes, then check what Google sees](#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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fhtaccess%20(%22404%20Not%20Found%20caused%20by%20.htaccess%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fhtaccess%20(%22404%20Not%20Found%20caused%20by%20.htaccess%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fhtaccess%20(%22404%20Not%20Found%20caused%20by%20.htaccess%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F404%2Fhtaccess%20(%22404%20Not%20Found%20caused%20by%20.htaccess%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

_01_How 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>
```

**Apache prefers config over .htaccess**The same guide says that if you have access to the main server config, you should avoid `.htaccess` files, citing performance and security: permitting them makes httpd look for `.htaccess` in every directory on every request. If you control the server, put these rules in a `<Directory>` block and set `AllowOverride None`.

_02_Fix it on your stack

## The four patterns that return 404

Front controller with rewrite rules (subfolder app)
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
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
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
| 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` |

 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

_03_Check 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](/glossary/http-status-codes)". Google's crawling docs add that a 2xx page whose content is an empty page or an error message can show in [Search Console](/glossary/google-search-console) as a [soft 404](/glossary/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](/errors/http/404) and [redirect to 404](/seo-issues/redirect-to-404) for the audit side.

**MultiViews can map URLs you did not plan for**Apache's negotiation docs say that with `MultiViews` on, a request for `/some/dir/foo` with no such file makes the server look for files named `foo.*` and pick the best match. It is a per-directory option and `Options All` does not enable it. If clean URLs behave oddly, check whether `MultiViews` is on.

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.

_01_ Why 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.

_02_ How 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.

_03_ What is RewriteBase for?

In `.htaccess`, mod_rewrite must turn a relative result back into a [URL path](/glossary/url-slug). 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.

_04_ FallbackResource 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. 01 [Apache httpd 2.4: .htaccess files](https://httpd.apache.org/docs/2.4/howto/htaccess.html) httpd.apache.org · checked 2026-11-01
2. 02 [Apache httpd 2.4: mod_rewrite and .htaccess](https://httpd.apache.org/docs/2.4/rewrite/htaccess.html) httpd.apache.org · checked 2026-11-01
3. 03 [Apache httpd 2.4: mod_dir (FallbackResource)](https://httpd.apache.org/docs/2.4/mod/mod_dir.html) httpd.apache.org · checked 2026-11-01
4. 04 [Apache httpd 2.4: core features (ErrorDocument, AllowOverride)](https://httpd.apache.org/docs/2.4/mod/core.html) httpd.apache.org · checked 2026-11-01
5. 05 [Apache httpd 2.4: content negotiation (MultiViews)](https://httpd.apache.org/docs/2.4/content-negotiation.html) httpd.apache.org · checked 2026-11-01
6. 06 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-11-01

## Keep learning

[All errors](/errors)

[Learn 404 Not Found HTTP status codes](/errors/http/404) [Related 4xx errors Status codes and links](/seo-issues/4xx-errors) [Read next 403 Forbidden in Apache HTTP status codes](/errors/http/403/apache) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 404 errors
[Firebase Hosting 404](/errors/cdn/firebase-hosting-404) [GitHub Pages 404 Not Found](/errors/cdn/github-pages-404) [404 Not Found](/errors/http/404) [404 Not Found in Django](/errors/http/404/django) [404 Not Found in Flask](/errors/http/404/flask)

More in 404 Not Found
[404 Not Found caused by .htaccess](/errors/http/404/htaccess) [404 Not Found in Django](/errors/http/404/django) [404 Not Found in Flask](/errors/http/404/flask) [404 Not Found in IIS](/errors/http/404/iis) [404 Not Found in WordPress](/errors/http/404/wordpress) [404 Not Found on Apache](/errors/http/404/apache) [404 Not Found on nginx](/errors/http/404/nginx)

Terms on this page
[HTTP status codes](/glossary/http-status-codes) [Google Search Console](/glossary/google-search-console) [Soft 404](/glossary/soft-404) [URL slug](/glossary/url-slug)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
