This is bizarre...

I have two posts that when I try to view them, they get a 301 and proceed to redirect to the next post in line. These posts are published. I don't have any plugins messing with redirections. I have tried disabling other plugins that could cause this issue. I have also checked the guid in the database and it's correct. The htaccess has the basic wp pretty permalink structure. For some reasons this 2 links have been marked as 301, and I can't see where this was done.

Any ideas?


This is getting really weird...

So trying to troubleshoot I did the following:

1. Download the site to local dev. I thought if the problem is the whole link, then if I change it to a dev link, the problem will no longer exist. And that would rule out domain level 301 redirect.

Turns out that the problem still exisits under a different domain name.

2. Disabled all plugins I disabled all plugins. The problem persisted. Just in case, I deleted all plugins. No luck.

3. Search for hard coded links I searched for hard coded links in the whole theme. I also searched for any php redirects or js redirects. Nothing.

4. So I resintalled the WP core I wanted to make sure that had nothing to do with it. Nothing.

5. I deleted all revisions

6. Disabled ACF custom fields plugin I thought that maybe the redirect is hidden in some custom field. So disabled the plugin that displays them. The theme barely display correctly but the page redirects anyway.

I cannot switch themes, because the whole logic of displaying this page is done in the theme, and uses a lot of custom post types and fields.

So the next option, was to delete the page that the redirect was pointing to. So I for example I have Post 1 redirecting to Post 2. I deleted Post 2 (trashed it). The redirect still took me to the Post 2 page, but of course that now I got a 404 instead. Since Post 2 is in the trash.

So I decided to delete Post 2 from the trash, so that it would no longer be in the database. Once I deleted Post 2... tada! Post 1 was no longer redirecting. That solves the issues, but clearly I cannot delete Post 2 on the live site...

I am still clueless as to what's going on...


So I wanted to be 100% sure that the problem is not in the files but in the database. So I deleted pretty much everything, and only left what's need to make the pages in questions load without errors. That means that I deleted everything from functions.php, deleted all templates but the ones affected, delete styles, images... everything. Deleted almost everything from header.php.. leaving only the doctype and style inclusion (that's where the theme name is). And the redirect still happens. I even removed wp_head, and no luck. So now I know that the problem is in the database.

2 Answers 2


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.


Usually when a 301 redirect occurs, the following could be happening:-

  1. You have some rogue .htaccess rewrite rules. In this case you may want to go to WordPress admin -> Settings -> Permalinks and then click on "Save Changes". This will rewrite the WordPress portion of the .htaccess file
  2. You have a redirect set up at domain level (this will require logging into your hosts control panel to see if anything is set up there).
  3. You have a client side redirection script.
  4. There is a setting Yoast SEO under the "Advanced" section that says "Redirect Ugly URL's to clean permalinks". http://scr.hu/76g8/b3c1d This has also caused redirect issues for clients that I've worked with.

What is the URL where the problem occurs? I think that will help us diagnose.

  • Thanks. So it's not 1, 3 or 4. I will check number 2 once I get access to that.
    – gdaniel
    Dec 14, 2015 at 17:56
  • Unfortunately I don't think it's number 2 either. I download the site to local dev, and the link is still redirecting. I disabled all plugins, and it stills redirect. I am going to switch themes next.
    – gdaniel
    Dec 14, 2015 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.