Changing WordPress Permalink Settings: Inconsistencies and Gotchas

Today’s article starts with a sad WordPress story, then explains why the sad story happened and what you can do to avoid it.

There’s also a video, which demonstrates inconsistencies in the way WordPress’s permalinks structures change—these inconsistencies caused the problem that the sad story describes. If you’re into watching things, you should start there!

A Sad Story about WordPress Permalinks

The sad story is indeed about WordPress permalinks. It’s a true story: it happened to me earlier this month. It goes like this:

  1. I volunteer with an organization that, among other things, helps young people fundraise on their own behalf for enriching personal travel. We’re handling this in WordPress (with the excellent Give plugin).
  2. Another person in the organization shared one young person’s fundraiser on Facebook. It went semi-viral, accumulating 100 or so likes.
  3. At around this time, I made some changes to the site’s permalink structure. Each fundraiser is of post type Post, and in my experience Posts have generally forwarded themselves through permalink changes.
  4. For this change, though, the forwarding didn’t work. The hundreds of clickthroughs from the Facebook post all went to a 404 page, and I began getting emails with subjects like “Urgent!!!” and text content like “I’m concerned that we’re throwing money away.”
  5. I manually 301ed that, and every, post on the site, and the problem subsided—but not before a lot of apologetic reposting on Facebook and an unknown number of lost donations.

Sad, right?

sad pikachu | wordpress

What Happened?

WordPress’s default permalink rewriting behavior is very strangely inconsistent.

So how did this happen?

It happened because, as it turns out: WordPress’s default permalink rewriting behavior is very strangely inconsistent.

In other words, let’s say I change mysite.com/post to mysite.com/my-post, but I’ve still got a Facebook post linking to mysite.com/post. What happens when you click the Facebook post?

The answer is: It’s very hard to predict. WordPress forwards rewritten URLs some of the time, depending on the nature of the rewrite—but not all the time, and the rules separating the conditions (as we’ll see) don’t make much sense. In fact, WordPress’s forwarding behavior is just enough, in my experience, to make you relax into a potential disaster.

Why it Matters When Permalinks Don’t Forward Properly

Defining “Forward Properly”

To keep this simple, and also to draw from my specific experience, we’ll use a very practical definition. A WordPress URL is forwarding properly if the following sequence can occur:

  1. Someone shares the original URL on Facebook
  2. The URL changes
  3. People who click on the Facebook post, after the URL change, still see the resource that was linked to on Facebook (and not a 404 page, homepage redirection, or anything else)

If your URL changes don’t meet this test, then people, and search engines, are failing to find your content.

If your URL changes don’t meet this test, then people are looking for, and failing to find, your content. And, to state the hopefully obvious, the “people” who are failing to find your content can also include search engine crawlers, heavily damaging your site’s SEO profile.

In other words, if you change your URLs, the change fails the above test, and you don’t do something about it, then like me on my site…

You played yourself WordPress

Testing WordPress Permalink Forwarding

After my uncomfortable surprise, I tested the way Permalinks work on two independent setups:

  1. A local WordPress install on WAMP, and
  2. A live site on SiteGround shared hosting

Apart from the need to clear the SiteGround site’s caching after every permalink change, both environments behaved similarly. Let’s look at which types of permalink changes do and don’t appear to “forward properly,” given the definition above.

Permalink Changes that Appear to Forward Properly

Renaming Individual Post URLs

For example, if you change wpshout.com/permalinks to wpshout.com/permalink-article, using the URL editor in the post editing screen, the URL will forward along properly. If you then visit wpshout.com/permalinks, you’ll still end up at wpshout.com/permalink-article.

This appears to be true by default for posts of any post type, including Post, Page, or a custom post type.

Some Changes to Permalink Settings

Permalink settings define your site’s general schema for how permalinks will be written.

wordpress permalink settings page

Changing these settings leads to the most unpredictable results in terms of URL forwarding. However, some changes do seem to consistently forward properly:

  1. Switching between “Day and name” and “Month and name” seems to work, in any direction.
  2. It appears to be possible to switch to “Numeric,” and to switch from “Post name,” without problem, although the opposite is not true (see below).

Permalink Changes that Appear Not to Forward Properly

Some Changes to Permalink Settings

The following permalink setting changes do not appear to forward affected URLs:

  1. Switching to “Post name” from any other permalink structure, except “Plain” (in other words, if you’re switching to “Post name,” it’ll only forward properly if you’re switching from “Plain”)
  2. Switching from “Numeric” to any other permalink structure
  3. Switching to “Plain” from any other permalink structure

Specifics on Switching to “Plain”

Switching to “Plain” actually leads to two different behaviors on the two sites I tested, neither of which is what I would expect. On my WAMP install, it creates a server error:

server error wordpress permalinks

On the live site, switching to “Plain” doesn’t attempt to forward at all. The old URL simply delivers traffic to the site’s homepage, which is the default behavior on that site for 404ing pages.

In other words, http://validcognition.com/2015/03/on-spirituality-and-cool/ should forward to http://validcognition.com/?p=1558, but instead simply 404s, exactly as would http://validcognition.com/not-a-real-url-asdfasdfasdf.

Video Summary of Inconsistencies

The following video demonstrates these behaviors:

What to Do About This

Especially if you’ve watched the video, you should have a good sense that WordPress’s permalink forwarding behaves very oddly and unreliably. So what can you do to prevent stories like the one that started this article? A couple of things:

Double- and Triplecheck Any Permalink Forwarding You Think WordPress May Be Doing

If you change permalink structures, go crazy checking that the old permalinks still forward. Check this for different post types, and for multiple posts.

Forward URLs Yourself

A number of WordPress plugins make it quite easy to create manual 301 redirect rules for forwarding URLs—rules that forceone URL to permanently point to another. The plugin I’ve mostly tried and liked for this is called Simple 301 Redirects.

Obviously, if you’re trying to forward, say, 2,000 blog posts, this approach is likely to be impractical. But if you’re really concerned about a couple of special of pieces of content (like the fundraiser post that was going viral on my site), backing up WordPress’s default behavior with manually written permalinks makes a lot of sense.

Sidenote on .htaccess Hacks

As a last note, I’ve checked a lot through the support threads on this topic, and they all recommend one or another .htaccess hack. I wouldn’t rely on that, since WordPress is displaying the same inconsistent behavior in two well-configured, and quite different, hosting environments. However, if I am missing something and an .htaccess hack can solve all this, let me know and I’ll be delighted to write a follow-up article!

Be Careful Out There!

WordPress’s permalink forwarding is a wild and woolly animal, and one which gave me a minor trampling last week. Please be careful with WordPress permalinks—and, in general, don’t always assume that you know what you think you know.

What’s your experience with WordPress permalink changes? We’d love to hear your questions and thoughts in the comments below!


5 Responses

Comments

  • By “archive”, do you mean “numeric”?

  • Thanks, Fred, this was very helpful to understand a similar problem we had with our blog page. Our traffic was in the basement for several days a couple of weeks ago until I discovered it was a permalink problem. After reading your article I found that it started when we posted a link at FB. That link was in the “Plain” setting instead of our typical Day and Name setting.

    But I don’t know how that Permalink setting got changed at our WP page in the first place. Any ideas?

    • Fred Meyer Fred Meyer says:

      Not sure without looking a bit more at the site in question (and it seems like the problem is already fixed) – but really glad you found the solution!

Pingbacks

  • […] When you change a WordPress site’s permalinks in Settings > Permalinks, you can open the site up to 404 errors. Unfortunately, WordPress is rather inconsistent in this regard, so the rules for what will and won’t redirect properly are not logical. I detailed some of the issues that arise here in an earlier article. […]