Does WordPress Redirect Old Slugs to the Correct Permalink Out-Of-the-Box?

brown wooden arrow signed

Although some plugins might make you believe you need them to automatically redirect from an old post slug to a new updated one – you don’t.

TL;DR: Yes.

Yoast’s claim

In some of my projects, I’m using Yoast SEO Premium, and so I used to get these notifications when changing the slug of a post or a page:

The Yoast SEO Premium plugin claims to have created a redirect from the old URL to the new URL. I thought it to be very nice of him, and that it is a great feature.

In the search for alternative

When starting my own blog, I looked for a better cost-effective solution for the important task of redirecting old slugs to the correct permalinks. After checking my options, and deciding not to install a dedicated plugin (I always prefer to keep things lean), I started playing with a simple PHP solution. While the code itself didn’t work yet, as I was testing it I noticed the aspired redirect did magically happen.

I’ve already noticed similar behavior in the past. But I always ascribed it to WordPress trying to guess slugs, which it apparently does, using the redirect_guess_404_permalink() function. This time, though, something inspired me to dig deeper. Pretty soon I’ve found a GitHub issue under the title of Automatically redirect old post slugs. One of the commenters claimed that:

“WordPress redirects old post permalink slugs automatically out of the box.”

Truly mind-blowing.

WordPress’s native old slug redirection mechanism

By that point, I already learned that there are several redirection plugins in the WordPress repository, one of them with over 2 million active installations and another with 300,000. You can add to this the above-mentioned Yoast SEO Premium functionality. It made me wandering – all of this for a pre-existing out-of-the-box core functionality?

And so I continued digging deeper and discovered WordPress’s core wp_old_slug_redirect() function. Its documentation states: “Redirect old slugs to the correct permalink”. The description adds: “Attempts to find the current slug from the past slugs”. Also, apparently, the function has been around for a long time. Since WordPress 2.1.0 to be accurate (back in 2007!). Just for fun, here’s the original Trac thread suggesting to merge the brilliant “Redirect Old Slugs” plugin to WordPress core. Maybe just some a bit more fun the last post on Mark Jaquith’s personal blog, by the person behind the original “Redirect Old Slugs” plugin, and where it was originally published, is about How to Cook Perfect Sous Vide Hard Boiled Eggs.

Sorry about it.

Anyway, the wp_old_slug_redirect() function seemed to be exactly what I needed. With further research, I’ve found out that it is hooked to the template_redirect action, and that one more related function wp_check_for_changed_slugs() is hooked to two other actions. Its name is pretty self-explanatory. The two functions are hooked under the note: “Redirect old slugs”, on /wp-includes/default-filters.php:

<?php //** From: /wp-includes/default-filters.php **// // Redirect old slugs. add_action('template_redirect', 'wp_old_slug_redirect'); add_action('post_updated', 'wp_check_for_changed_slugs', 12, 3); add_action('attachment_updated', 'wp_check_for_changed_slugs', 12, 3);
Code language: HTML, XML (xml)

So the answer is “Yes, WordPress does redirect old slugs to the correct permalink out-of-the-box”.

Why do plugins make you think you need them?

Then two questions came to my mind:

  1. Why are redirection plugins so popular?
  2. Do redirection plugins acknowledge or mention WordPress’s core old slugs redirection functionality?

Of course, the answer to the second question can partially answer the first one. And so I checked. Yoast has a dedicated feature page for their premium Redirect manager, and under the heading “Why do I need a redirect manager?” its says:

When you delete a page, it doesn’t just disappear from the search engine index. People can still find it, and land on it. When they do, they’ll find a 404 error. That’s a poor user experience, and can be harmful to your SEO. It’s really important to avoid those dead-ends.

The Yoast SEO Redirect Manager helps you to create and manage redirects, which stop users and search engines from getting lost. It even automatically creates redirects whenever you move or delete content. That’s great for users, great for search engines, and great for your workflow!

[emphasis in original]

So not only that Yoast doesn’t mention the built-in WordPress functionality, but it states, in an emphasized sentence, that their plugin’s functionality is the one that “automatically creates redirects whenever you move or delete content“. It goes further to imply that without it users will encounter 404 errors.

As far as moved content – we already know enough to claim Yoast statement not true: WordPress automatically created redirects for moved content out-of-the-box. Regarding deleted content, it’s true that WordPress just leaves 404s, but according to John Mueller (Senior Webmaster Trends Analyst at Google), 404s are perfectly fine. As for 404 vs. 410 redirects:

“From our point of view, in the mid-term/long term, a 404 is the same as a 410 for us. So in both of these cases, we drop those URLs from our index.


The subtle difference here is that a 410 will sometimes fall out a little bit faster than a 404. But usually, we’re talking on the order of a couple of days or so.

So if you’re just removing content naturally, then that’s perfectly fine to use either one. If you’ve already removed this content long ago, then it’s already not indexed so it doesn’t matter for us if you use a 404 or 410.”

John Mueller, as published in the Search Engine Journal

And as for redirecting 404s to home pages, Muller tweets in reply to a question about the subject:

See more related links on the subject of 404s and Google at the end of the post.

So, what Yoast presents as a great selling point, actually isn’t a selling point at all. If I’m not missing something, this is pretty misleading. True, Yoast Redirect manager does introduce added functionality (namely the ability to manage the redirects), but many sites can do just fine without it. Anyway, it is one thing to enhance a pre-existing feature, and another to claim to introduce it on the whole.

BTW, the popular Redirection plugin on WordPress’s repository also states:

“The plugin can also be configured to monitor when a post or page permalinks are changed and automatically create a redirect to the new URL.”

Again, the plugin doesn’t mention WordPress’s core redirection functionality and appropriates it to itself.


Although some plugins, even premium ones, offer automatic redirects for changed content slugs – it is actually a built-in WordPress functionality. The fact that redirection plugins are so popular might have something to do with them claiming to invent this feature. It seems to be another case of WordPress being great, but lacking in PR. At least here it only loses customers internally.

External links

WordPress’s automatic old slugs redirection

404s and Google

Was the post helpful?

2 responses to “Does WordPress Redirect Old Slugs to the Correct Permalink Out-Of-the-Box?”

  1. Hi Asaf,

    I understand that the true value offering of the redirect plugins is in the case of permalink structure changing. Because when you change permalink structure (not just changing a slug), the process of redirection is not automatical.

    I thought that this was an automatical in the permalink changing case, but not, WordPress only considers the slug changing case. I confirmed this with your post, so thank you for that!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: