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
.htaccessfile 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.
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.
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.
This is what my results were.
Click on “Browse” next to the
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.”
Press “OK” on the confirmation.
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.
And that’s it!
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.