Debug Ghosts, Part III
How a split-second Page-Not-Found flash revealed a hidden routing bug
A website that “mostly works” can be more dangerous than one that fails outright.
This is the story of a one-frame Page-Not-Found flash that appeared after clicking a splash screen — and how it led to uncovering a subtle but critical routing flaw: two valid entry points pointing to the same application.
The Problem: A Flash That Shouldn’t Exist
Click splash →
blink “Page Not Found” →
homepage loads normally.
No console errors.
No PHP warnings.
No failed navigation.
But the flash was real — and repeatable.
This wasn’t a rendering glitch. It was a real HTTP request resolving to the wrong route for just long enough to be visible.
Why This Bug Was Hard to See
Browser DevTools didn’t immediately reveal the problem:
-
Network filters hid short-lived redirects
-
Third-party iframes dominated the timeline
-
The final destination looked correct
Only server-side logging at the front controller exposed the truth.
A single click triggered multiple document requests.
The Root Cause: Two Entry Points, One Application
The application was accessible through two paths:
-
/focus-local/index/... -
/focus-local/public/index/...
Only one was fully wired.
The splash screen linked to the wrong one first — then the app redirected itself to the correct path.
That first request briefly rendered a Page-Not-Found template before disappearing.
Visualizing the Bug (Bad vs Good Flow)
❌ Broken Flow (Before)
flowchart-1 flowchart-2 flowchart-3 <====== Click a link.
Splash Click↓/focus-local/index/1 ← wrong entry point↓(Page Not Found renders briefly)↓Redirect↓/focus-local/public/index/1
✅ Correct Flow (After)
flowchart-4 flowchart-5 flowchart-6 <====== Click a link
Splash Click↓/focus-local/public/index/1↓Homepage renders cleanly
One request.
One entry point.
No flash.
The Fix: Canonical1 URLs + Defensive Redirects
1. Fix the Splash Screen Link
Before
<a href="{{ doc_root }}index/1">
After
<a href="/focus-local/public/index/1">
No ambiguity. No guessing.
2. Add a Safety Net in the Front Controller
In public/index.php, early — before routing:
if (strpos($_SERVER['REQUEST_URI'], '/focus-local/index/') === 0) {header('Location: /focus-local/public' .substr($_SERVER['REQUEST_URI'], strlen('/focus-local')),true,302);exit;}
Even if a bad link sneaks in later, the wrong page can never render.
Why This Matters (Beyond This Bug)
This wasn’t a JavaScript issue.
It wasn’t a session issue.
It wasn’t a template issue.
It was an architectural hygiene issue.
If an application can be entered two ways, one of them will eventually be wrong.
Debug Ghosts: Key Takeaways
-
Log at the front controller when behavior feels impossible
-
Don’t rely on DevTools alone for short-lived routing bugs
-
Eliminate duplicate entry points early
-
Treat “works most of the time” as a warning sign
Ghost bugs don’t disappear when ignored.
They disappear when you force the system to be unambiguous.
TFOL Dev Series: Debug Ghosts
This post is part of the ongoing Debug Ghosts series — real-world debugging stories from rebuilding The Focus On Life platform.
📘 Part I
Debug Ghosts: How Twig and PHP Made Me Question Reality
→ Template inheritance, variable shadowing, and logic that looked right
📘 Part II
Debug Ghosts, Part II: Why Opening DevTools Fixed My Layout
→ CSS reflow, viewport scaling, and the illusion of “DevTools magic”
📘 Part III
Debug Ghosts, Part III: When Two Entry Points Become One
→ Canonical URLs, routing discipline, and killing the Page-Not-Found flash
______________________________________________________________________________________________________
1What “canonical” means (plain English)
Canonical means:
the single, authoritative, officially recognized version of something
In other words:
“This is the one true version — treat all others as copies.”
A canonical URL tells browsers and search engines:
“If this content appears at multiple URLs, this one is the real one.”
Example:
/focus-local/index/1
/focus-local/public/index/1
/focus-local/public/index/1?ref=splash
These might all show the same page.
The canonical URL is the one you want everyone (and Google) to treat as the real page:
/focus-local/public/index/1
Posted in ghost-stories by TFOL BLOG