Why am I getting a 301 on a existing post?

After pretty much destroying the website (copy) I found the answer, but I am not 100% sure of the cause.

WordPress saves the name of old posts slugs, so that it can create 301 redirects. It adds an entry to the postmeta table called _wp_old_slug. I had over 110 entries on my postmeta table with many different values. There were a whole bunch of posts with the wrong value. I am not sure how this happened, but this was causing the 301 redirects. As soon as I removed these entries from the database the problem was fixed.

Maybe _wp_old_slug functionality broke during one of the updates? And it was fixed it later without anyone noticing? I am not sure, but I had not even heard of this before. I got clues to my solution thanks to this website.

Leave a Comment