We shipped a bug in BerqWP, our WordPress speed plugin, that did exactly this. Here's what happened, why it's easy to miss, and a one minute test to check your own site.

The bug

WordPress picks one version of every URL. On most sites that's the one with a trailing slash, like /about/. If someone visits /about, WordPress sends a 301 redirect to /about/. One page, one URL.

Our page cache broke that. /about and /about/ shared the same cache file. When a request came in for /about, the cache found the file and served the page right away with a 200 OK.

The redirect never happened. Google now had two working URLs with the same content.

Why the redirect got skipped

The redirect lives inside WordPress, in a function called redirect_canonical(). It only runs after WordPress loads.

A page cache exists to skip that. It runs before WordPress, in advanced-cache.php or in server rules like .htaccess. That's what makes it fast. It's also why everything WordPress would normally do on that request gets skipped, including the redirect.

So this isn't only our problem. Any cache that serves both versions of a URL from the same file, before WordPress runs, can do the same thing.

What it looked like in Search Console

URLs without the slash started showing up under "Indexed, not submitted in sitemap". Your sitemap only lists /about/, so Google found a URL you never told it about and indexed it anyway.

WordPress also adds a canonical tag that points to /about/. That helps, but a canonical tag is a hint, not a rule. A 301 is a clear answer.

Test your site in one minute

First, load the normal URL so it gets cached:

curl -s -o /dev/null https://example.com/about/ 

Then request it without the slash and check the status:

curl -sI https://example.com/about | head -n 3 

Good result: a 301 with a location header pointing to /about/.

Bad result: a 200. Your cache is serving the page at the wrong URL.

If your site uses URLs without a trailing slash, flip the test. Cache /about first, then request /about/.

Try it on a few pages. If you use Cloudflare or a host cache, this tests the whole chain, which is exactly what Google sees.

How we fixed it

The fix was simple in idea. Make the cache do the redirect itself, before serving anything.

The tricky part was timing. Our cache runs in advanced-cache.php, before WordPress connects to the database. So it can't ask WordPress what the permalink structure is. We now save that setting to the plugin's config file when WordPress loads, and the cache reads it from there.

Then, right before serving a cached file, it checks the slash:

$has_trailing_slash = substr($request_path, -1) === '/'; if ($wants_trailing_slash !== $has_trailing_slash) { $path = $wants_trailing_slash ? rtrim($path, '/') . '/' : rtrim($path, '/'); header('Location: ' . $scheme . $host . $path . $query, true, 301); exit; } 

Two details mattered.

We only redirect when we're about to serve cache. If there's no cached file, WordPress handles the request and makes the call itself. That keeps REST API routes safe, because WordPress never redirects those.

We also changed the server rules in .htaccess so they only serve cache for the right form of the URL. Otherwise the server would hand out the cached page before our PHP check ever ran.

The fix shipped in version 4.1.18.

If your test failed

  1. Update your cache plugin, or fix your cache rules, so the wrong form returns a 301.
  2. Clear the cache.
  3. Run the curl test again.

You don't need to remove the extra URLs from Google by hand. Once Google crawls them again and sees the 301, it drops them over time.

The takeaway

A cache that skips WordPress also skips everything WordPress does on that request. Redirects are the easiest thing to lose, and you won't notice in the browser. Run the test.