How to fix old WordPress URL redirecting to a new URL

This is a little problem I ran into today and so, of course, I thought I would share it with you. I had a blog post that I renamed and changed the slug because I had a better article which I wanted the slug for.

Google loves short URLs and I had a 4,000+ word post that I needed the slug for.

Normally I don’t recommend changing slugs, but the original post was only live for a few days so there weren’t any backlinks against it or even indexed yet. The problem I ran into was that my old post suddenly was redirecting to my new URL.

If you’re having issues with WordPress URLs redirecting when they shouldn’t, you should first check a couple of things:

  • Check your .htaccess file to make sure you don’t have any manual 301 redirects.
  • Check your SEO or redirect plugin.
  • Check to ensure you haven’t added a server-level redirect. For example, Kinsta lets you add redirects from their MyKinsta dashboard.
  • Check your categories, and trash because they might be stealing the slug (URL).

In my case, my post was still redirecting, even after checking everything above.

So here is what happened. WordPress has this convenient feature of remembering the old URL and redirecting to the new URL so that your links aren’t broken. While this is cool and dandy, it also can cause frustration because there is no way to see this from the WordPress dashboard. And no it doesn’t show up under custom fields.

The only way to remove this old entry is from your database directly.

Fix old WordPress URL redirecting

Follow the steps below to fix an old WordPress URL redirecting to a new URL.

Step 1

Login to your database via phpMyAdmin. If you don’t know how I recommend stopping now and forwarding my post to your web host with a description of what is happening and let them do it for you. Or at least backup your database first.

phpMyAdmin

Step 2

So in my case, the URL that was redirecting wrong was domain.com/ulcerative-colitis. This is on a gluten-free website that I run. So the slug is “ulcerative-colitis.” In phpMyAdmin click into your database and into the “Search” tab. Then select all the tables and run the search for your slug.

database search
Database search

This is what my results were.

wordpress database results
WordPress database results

Step 3

Click on “Browse” next to the wp_postmeta table.

Step 4

There will be a meta_key entry for _wp_old_slug. Select that and delete it. You can see below that the meta_value is my slug “ulcerative-colitis.”

wp old slug
WordPress old slug

Press “OK” on the confirmation.

delete wp old slug
Delete old WordPress slug

Note: I was able to confirm the post_id of 378 by going into my WordPress dashboard, hovering over “edit” on the post, and looking in my browser at the post ID.

edit this item wordpress
Edit post
post id wordpress
Post ID in WordPress

And that’s it!

Summary

After deleting that entry your post should no longer redirect. If this post on how to fix your old WordPress URL from redirecting to the new URL was helpful let me know below.

author bio
Brian Jackson

I craft actionable content and develop performance-driven WordPress plugins. Connect on X, subscribe to my newsletter (once a month), or buy me coffee.

12 thoughts on “How to fix old WordPress URL redirecting to a new URL”

  1. Hello Brian, This one is brilliant post.
    I want to know from you how to show ‘Last Update’ date in Google SERPs instead of publish date? I’m feeling little bit confused weather, Google pick date from Last Modified header response or directly from meta properties. Also, sometime I have seen that Google has shown last 3 days ago like that whenever I have updated my post by adding in-depth paragraph.

    Reply
  2. In order to ensure good traffic to your website, you need to make sure that the pages are directed correctly. The issue of WordPress URLs getting redirected is something that should be given prime importance. The article helps to solve one of the major threats faced by web designers.

    Reply
  3. You need to make a change to your database. In the database table wp_options (or whatever your database prefix is), you need to change two lines.

    Reply
    • Hey Johns,
      No that is a different problem. That is if you migrate a site. The solution above is for when you change a URL on the same site.

      Reply
  4. Thank you very much for this tutorial. It helped me getting rid of hundreds of totally useless redirects.
    Best regards, Tooni

    Reply

Leave a Comment

4