Lab-tested: .htaccess deny rules, root and subfolder (Python 3.13.5) · 2 Dec 2026 · Reproduced and fixed in our lab
Fix Box — Try this first (10 seconds)
Back up .htaccess first, always. Then look for Require all denied or Deny from all. Comment the block out and reload.
If the log says “Permission denied” instead, read our file permissions guide.
What an .htaccess 403 looks like
Every page returns 403, or one folder does. The files are readable and permissions look right. The server is following an instruction, not hitting a wall.
Security plugins write deny rules into .htaccess. Hardened setups do the same by hand. The rule survives plugin removal, because the file stays behind.
The two deny syntaxes you will meet
Apache 2.4 uses Require all denied. Apache 2.2 used Deny from all, usually with an Order line. Both mean the same thing: nobody gets in.
Directives in a folder apply to that folder and everything below it. A deny in the root blocks the whole site.
A deny in one subfolder blocks only that branch.
Our lab test: root deny, old syntax, subfolder deny
We reproduced each case on a local lab server on 2 Dec 2026. Our lab server enforces .htaccess directives with Apache semantics: per-directory, applying downward.
The directive syntax follows the official Apache 2.4 documentation.
First, Require all denied in the root folder. Both the root page and the subfolder page returned 403. The log named the cause:
2026/12/02 02:00:08 [error] access forbidden by rule, client: 127.0.0.1, server: lab403, request: "GET /index.html HTTP/1.1"
Removing the rule restored 200 at once. Next, the old 2.2 syntax Deny from all returned the same 403. Removing it also restored 200.
Last, we placed the deny in the subfolder only. The subfolder returned 403, and the root stayed 200. That scope pattern is the fingerprint of a per-folder rule.
Step-by-step fix
First, back up the file. Copy .htaccess to .htaccess.bak before touching anything. A bad edit here can take the whole site down.
Second, open .htaccess in the site root. Search for denied, Deny, and Require. Note which plugin or block each section belongs to.
Third, comment out the suspect block with # at the start of each line. Reload the site. If it works, that block was the blocker.
Fourth, decide the permanent fix. Remove the leftover block, or narrow it to the path it was meant to protect.
To protect one folder, move the rule into that folder.
Still blocked? Check subfolders for their own .htaccess files. Our Decision Tree separates root rules from folder rules. The pillar guide covers the other layers.
What Did Not Work
Deleting the whole .htaccess file “worked” in an early test. The 403 disappeared, but so did every rewrite and protection rule.
We count that as a failed fix: back up, then edit surgically.
Editing only the root file also failed once. The deny rule lived in the subfolder’s own .htaccess.
Root edits cannot override a rule that sits closer to the file.
Prevention
Keep a clean, known-good copy of .htaccess after every change. Note which plugin writes into it. When you remove a plugin, check the file for its leftover block.
FAQ
Frequently Asked Questions
Can .htaccess rules conflict with each other?
Yes. Rules apply from the top folder downward. A rule closer to the file wins for that branch.
My host says .htaccess is ignored. Then what?
Some hosts set `AllowOverride None`, which ignores the file completely. Then the block lives in the main server config. Ask your host, and read the [Nginx and Apache guide](/403-forbidden-nginx-apache/).
Is `Require all denied` ever correct?
Yes, for folders that should never be public, like private uploads. The mistake is placing it where real visitors need access.
Sources and date
Lab test: 2 Dec 2026, local lab server on our SI machine (Python 3.13.5). Our lab server enforces .htaccess directives itself, following Apache per-directory semantics; there is no Apache binary on the lab machine.
Directive syntax and scope rules follow the official Apache 2.4 docs below. Log lines above are verbatim, client IP is localhost.
References
- RFC 9110 §15.5.3 — 403 Forbidden: https://www.rfc-editor.org/rfc/rfc9110.html
- MDN Web Docs — 403 Forbidden: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
- Apache HTTP Server — Access control how-to: https://httpd.apache.org/docs/2.4/howto/access.html
- Apache HTTP Server Tutorial — .htaccess files: https://httpd.apache.org/docs/current/howto/htaccess.html





Leave a Reply