--- id: ck-ops-1 title: "Extensionless page goes dark after creating a same-named directory (Apache DirectorySlash)" type: issue-resolution applies_to: plan: [apache-httpd] region: all version: "2.4 · mod_dir + mod_rewrite, .htaccess context" owner: j-odonnell lifecycle: current verified: "2026-09-08" sections: - id: "ck-ops-1#environment" self_contained: true - id: "ck-ops-1#issue" self_contained: true - id: "ck-ops-1#cause" self_contained: true - id: "ck-ops-1#resolution" self_contained: true - id: "ck-ops-1#verify" self_contained: true --- ## Environment {#environment} Apache 2.4 on shared hosting, serving a static site. Clean extensionless URLs (`/page` serving `page.html`) come from mod_rewrite rules in the docroot `.htaccess`. mod_dir is active with its default `DirectorySlash On`; directory listings are disabled. ## Issue {#issue} On an Apache site that serves extensionless clean URLs, creating a subdirectory with the same name as a page (`page/` next to `page.html`) makes the bare URL `/page` stop serving. It returns a 301 redirect to `/page/`, which returns 403. URLs deeper inside the new directory keep working, so the breakage is easy to miss. A plain fetch of the bare URL can look like a stale page, because the response body is the redirect stub — check the HTTP status line before diagnosing content. ## Cause {#cause} mod_dir's trailing-slash redirect (`DirectorySlash On`, the Apache default) fires for any request URL that maps to an existing directory, and it wins before the per-directory mod_rewrite rule that would serve `page.html`. The slash-redirected URL then returns 403 because directory listings are disabled and the directory has no index document. ## Resolution {#resolution} In the docroot `.htaccess` of an Apache site whose extensionless page is shadowed by a same-named directory: 1. Set `DirectorySlash Off` so the trailing-slash redirect no longer preempts the rewrite to `page.html`. 2. Keep `Options -Indexes` set explicitly. With `DirectorySlash Off`, a bare directory URL is otherwise eligible for a listing wherever autoindex is enabled. 3. Add a one-hop 301 from the slashed form back to the canonical extensionless URL. The rule from the incident this article records (the page `/field-notes` on contextkeeping.com, shadowed by a new `field-notes/` directory): `RewriteRule ^field-notes/$ https://contextkeeping.com/field-notes [R=301,L]` 4. Add the verification probes below to the deployment checklist, so the next same-named directory cannot ship the regression silently. ## Verify {#verify} Run three probes against the live Apache site after uploading the `.htaccess` that resolves a directory-shadowed extensionless page. These are the probes from the recorded incident, and they pass against the live site today: curl -sI https://contextkeeping.com/field-notes | head -1 # expect: HTTP/1.1 200 OK curl -sI https://contextkeeping.com/field-notes/ | grep -i "^location" # expect: one hop to /field-notes curl -sI https://contextkeeping.com/field-notes/system-of-record | head -1 # expect: HTTP/1.1 200 OK All three passing means the page serves, the slashed form canonicalizes in one hop, and the directory's real children are unaffected.