A small DNS mystery, a forgotten configuration, and a developer fighting his own ghost
There is a special kind of horror in software development.
Not the horror of production going down.
Not the horror of a database migration deleting half your customers.
Not even the horror of seeing npm install produce 4,000 vulnerabilities.
No.
The true horror is opening a project you built months ago and realizing:
"Who the hell configured this?"
Then you remember.
"Oh no."
It was you.
The Strange Case of the Website That Worked Too Well
The story begins with a simple thought.
A website should have one canonical URL.
One identity.
One home.
Because apparently, even websites can suffer from identity crises.
A visitor should not have to wonder:
"Am I looking at the real website?"
"Is this the official version?"
"Did I accidentally enter through the back door?"
So naturally, I wanted:
www.example.com
to become:
example.com
Simple.
Clean.
Professional.
A five-minute task.
Which, in developer time, means:
"Prepare yourself for three hours of confusion."
The First Investigation: Blaming DNS Because DNS Is Always Suspicious
The first suspect was DNS.
Because when something involving domains breaks, developers have a natural reaction:
"Must be DNS."
It's the IT version of blaming the printer.
Nobody knows exactly what happened.
Everyone is slightly afraid.
And somehow, it is usually involved.
So I checked the records.
The setup looked reasonable.
The domain existed.
Cloudflare was there.
The website loaded.
Except...
The www version was not redirecting.
It was just existing.
Living its own life.
Like a forgotten server running somewhere in a basement.
The Plot Twist: The Website Was Not Broken
Then came the investigation.
The www version loaded.
The non-www version loaded.
Both displayed the same application.
At first, this looked wrong.
Because technically:
www.example.com
and
example.com
are two different URLs.
Two different addresses.
Two different possible identities.
Search engines could see them as separate pages.
The internet had accidentally created a clone army.
The Search Engine Already Knew the Answer
Then came the discovery.
The website already had:
The entire time.
The younger version of me had already solved the problem.
Not with redirects.
Not at the infrastructure layer.
But through SEO.
Because back then, I was deep in my:
"Frontend developer discovers SEO and becomes temporarily obsessed with metadata"
era.
Every page had:
titles
descriptions
Open Graph tags
canonical URLs
structured data
probably a prayer to Google somewhere
Past me basically looked at duplicate domains and said:
"Don't worry. I will simply tell the search engine which one is the chosen child."
And it worked.
The Second Website Revealed the Evolution
The newer setup told the story of my evolution.
The problem was the same.
But the solution moved down the stack.
Instead of:
Browser
↓
Website
↓
Canonical tag
↓
Search engine understands
The newer approach became:
Browser
↓
Cloudflare
↓
301 Redirect
↓
Website
The request never reaches the application.
The edge handles it.
Cleaner.
Faster.
More infrastructure-minded.
The frontend developer became a backend developer.
The backend developer became a DevOps developer.
The DevOps developer became the person staring at DNS records at midnight wondering why life choices led here.
The Actual Bug: I Forgot My Own Configuration
This was the funniest part.
The problem wasn't that the setup was wrong.
The problem was that I forgot why it existed.
Months later, I saw:
a
wwwdomaina Cloudflare configuration
a working website
and my first thought was:
"Who made this mess?"
Unfortunately:
git blame
would have immediately exposed the criminal.
Me.
The Fix: Make the Edge the Bouncer
The final solution was simple.
Instead of allowing two public entrances:
www.example.com
example.com
the preferred setup became:
www.example.com
|
|
↓
301 Redirect
|
↓
example.com
The edge decides.
The application stays clean.
Search engines get one identity.
Visitors get one URL.
Everyone goes home happy.
Except the developer maintaining it six months later.
He still suffers.
The Lesson: Old Code Is A Message From Your Past Self
The funny thing about software is that your old code is not always bad.
Sometimes it is just a conversation you forgot having.
Past you did not fail.
Past you solved the problem with the tools and knowledge available at the time.
Then future you arrived with more experience and immediately accused past you of incompetence.
Classic developer behavior.
We don't just fight bugs.
Sometimes we fight previous versions of ourselves.
And occasionally...
we lose.
Final Thoughts: The Developer Lifecycle
The progression is almost predictable.
Stage one:
"How do I make Google understand my website?"
Stage two:
"How do I make the infrastructure enforce this?"
Stage three:
"Why did I configure it this way?"
Stage four:
"Oh."
The real senior developer skill is not knowing everything.
It's being able to look at your old work and say:
"This is weird."
followed five minutes later by:
"Wait. This is actually pretty good."
Then quietly close the tab before your ego notices.