Platform · IIS · Sitecore

The 404 Page That Wasn't a Front-End Bug

Visitors who hit a broken link were supposed to see a friendly, branded "page not found" page. Instead they got a plain server error page. It looked like a front-end problem. It wasn't even in the application.

The wrong kind of not found

Every brand site has its own "page not found" page, built and managed in Sitecore. It matches the brand, offers a search box, and points people back to something useful. It's a small thing, but it's the difference between "oops, try this" and "you're lost, good luck."

On several brand sites, mistyped or outdated URLs were skipping all of that. Visitors got a bare, unbranded server error page instead. Same problem on multiple sites at once, which is always a clue.

The obvious suspects

My first guesses were all inside Sitecore. Maybe the not-found page was missing or unpublished. Maybe a site's settings pointed at the wrong item. Maybe Sitecore's own error handling was misconfigured after a change.

But the branded page existed, it was published, and it loaded fine when I went to it directly. The content was right and the site settings looked right. So the question changed from "what's wrong with the page?" to "why isn't anyone getting to it?"

Who answers a 404?

A request to a Sitecore site goes through IIS, the Windows web server, before Sitecore ever sees it. Sitecore can decide a page doesn't exist and render a branded not-found page. But IIS has its own error handling too, and it gets a say in what the visitor finally receives.

IIS can be told to replace any 404 response with a static file of its own. When that's configured, it doesn't matter what Sitecore renders. IIS swaps in its file on the way out. That's exactly what was happening: IIS was set up to serve a static .htm file for 404s, so the branded Sitecore page never made it to the browser.

Visitor requests a page that doesn't exist
        ↓
Sitecore: "not found" → renders the branded page
        ↓
IIS error handling sees the 404 status
        ↓
  Before: replaces the response with a static .htm file
  After:  lets the Sitecore-rendered page through

How you'd spot this

The tell is when the page works on its own but not as an error. A quick way to see who is actually answering is to request a URL that doesn't exist and look at both the status code and the body. If the body is a generic server page instead of your site's HTML, something in front of the application is stepping in.

In IIS, that something lives in the custom error settings (the httpErrors section). A configuration like this one tells IIS to use its own file for 404s:

<!-- Illustrative: IIS serving its own static file for 404s -->
<system.webServer>
  <httpErrors errorMode="Custom">
    <remove statusCode="404" />
    <error statusCode="404" path="404.htm" responseMode="File" />
  </httpErrors>
</system.webServer>

The fix

I updated the IIS error handling so 404s route through Sitecore's managed not-found page instead of the static file. Then I checked it across the affected brand sites to make sure each one now landed on its own branded page.

The change itself was small. Finding the right layer was the real work.

What I took away

This is one of my favorite kinds of bugs: it looks like a front-end problem, but the front end is fine. You only find it by following the request all the way from the browser to whatever actually answers it.

  • When the same bug shows up on several sites at once, look at what they share.
  • If a page works when you visit it directly, the problem is in how requests get there.
  • Follow the request through every layer. The application isn't the only thing that touches it.
  • Web server settings can change what users see just as much as front-end code can.