(Note to future readers: This is fixed in WordPress 3.3, so this article is now out-of-date. See http://core.trac.wordpress.org/changeset/18541 for the patch.)

I was not aware that other people didn’t know about this until recently, but since it seems to be little known, I thought I’d write a post on the topic.

Chain LinksIn WordPress, you should never start the custom permalink string with any of these %postname%, %category%, %tag%, or %author%. (Unless you know what you’re doing, of course. :) )

Meaning that “%category%/%postname% ” is a bad custom permalink string. So is just “%postname%” for that matter.

Why? Well, it has to do with how the WordPress Rewrite system works.

Rewriting Explained

See, when you request a URL from a WordPress site, WordPress gets the URL and then has to parse it to determine what it is that you’re actually asking for.

It does this by using a series of rules that are built whenever you add new content to WordPress. Generally the list of rules is pretty small, but there are specific cases that can cause it to balloon way out of control.

Normal Rules

Let’s say you’re using a normal permalink string, like my preferred “%year%/%postname%”. The rules that are generated will look like this:

/robots.txt (for the privacy settings)
/feed/* (for normal feeds of any kind)
/comments/* (for comments feeds)
/search/* (pretty url for searches, not often used)
/category/%category% (category archives)
/tag/%tag% (tag archives)
/author/%author% (author archives)
/%year%/%month%/%day% (with each of those after year being optional)
/%year%/%postname% (this is the permalink string you define)
/%pagename% (any Page)

The way that system works is that it compares the URL it has to each of those in turn, from the top to the bottom. When one of them fits, then WordPress knows what to display and how to do it.

Note that the order I listed those in is is significant. Each one from the top down is less specific than the previous one.  For example, “robots.txt” matches only that, while “/feed/*” matches anything starting with /feed/. And so on down the list. The %postname%, %category%, %tag%, %author%, and %pagename% will match any string, but the other WordPress % ones will only match numeric fields. Like %year% is always a number.

Notice that the last one is %pagename%. This basically matches everything, because %pagename% can be anything at all. Even hierarchical pages like /plugins/whatever/something will cause this to match. It’s the fall-through position. And then, if that page doesn’t actually exist on your site, then this causes the query to trigger the 404 condition internally, which causes your theme’s 404.php to load up.

Pretty simple and straightforward, really.

Problem Rules

The problem comes in when you try to use a non-number for the beginning of your permalink string. Let’s examine those last two rules closer:

/%year%/%postname% (this is the permalink string you define)
/%pagename% (any Page)

What if you used “%category%/%postname%” for your custom permalink string? Now those last two rules are these:

/%category%/%postname% (this is the permalink string you define)
/%pagename% (any Page)

That violates our main rule, doesn’t it? That each one should be less specific than the one above it? Because %category% can match any string too, just like the %pagename% can… With this set of rules, there’s no way to view any of the Pages. Not good.

So, WordPress detects this condition and works around it. Internally, this sets a flag called “use_verbose_page_rules”, and that triggers the rewrite rebuild to make this set of rules instead:

/robots.txt (for the privacy settings)
/AAA
/BBB
/CCC (one of these for each of your Pages)
/feed/* (for normal feeds of any kind)
/comments/* (for comments feeds)
/search/* (pretty url for searches, not often used)
/category/%category% (category archives)
/tag/%tag% (tag archives)
/author/%author% (author archives)
/%year%/%month%/%day% (with each of those after year being optional)
/%category%/%postname% (this is the permalink string you define)

Now we have basically the same set of rules, except for those new ones at the top. Every Page now gets its own very specific rule, and this satisfies our main condition once again.

Pages

But what if you have a lot of Pages? I once read a post by a person who had over 50,000 Pages on his site. That is a special case obviously, but consider our lookup system. We’re going through these rules one at a time. With our first method, our rule list was only 10 rules, maximum. With this new method, you add a rule for every single Page you make. Going through 50,000 rules takes a lot longer than going through 10. And even just building that list of rules can take a long time.

Basically you’ve created a performance issue. Your Pages now won’t scale to unlimited numbers. Your site’s speed is linearly dependent on the number of Pages you have.

This is a bad thing.

Conclusion

Firstly, it’s really not any better for SEO to have the category in there, or to have just the postname there by itself. And anybody who tells you differently is wrong. If you disagree with me, then no, I’m not interested in arguing this point with you; you’re just wrong, period, end of discussion.

Secondly, shorter links are great and all, but hell, why not use a real shortlink? WordPress 3.0 now has a ShortLink API that defaults to using ?p=number links on your own domain. These will actually work for any WordPress site, even ye back unto WordPress 2.5. WordPress 3.0 just makes it nicer and easier to use these with the Shortlink API (as well as allowing plugins to make this automagically use services like wp.me or bit.ly). So use that instead.

The conclusion is, in general, just don’t do it. Leave a number, or something static, at the beginning of your permalink string and you’ll never have any sort of problems. But if you really MUST do this sort of thing, then keep your number of Pages low. Don’t try it when you have more than, say, 30-50 Pages.

Addendum

Okay, so I actually simplified things for this post. It’s actually worse than this, as verbose page rules can add much more than one rule per page, as this post demonstrates (he gets 11 per extra page!).

Shortlink:

291 Comments

  1. Mr. Otto,
    I think you left out at least two kind of permalink strings.
    /%post_id%-%category%/%postname%/
    /%yeay%%monthnum%/%postname%/ (no dash between year and month)
    What if I use them as permalinks? Do they slow down my blog?

  2. Shocking insight:
    Even using a static string as the first part will not keep wordpress from adding verbose rules. See /wp-includes/rewrite.php, l. 1984 (orwell, anyone?; line number may be invalid for wp != 3.0.3) the regex deciding whether or not to use verbose page rules is:
    ^[^%]*%(?:postname|category|tag|author)%
    where the first part, [^%]*, would match anything except structure tags (including slashes!). so the only cures seem to be a) kicking pretty urls (as you mildly suggest) or b) making pretty urls start with one of the remaining structure tags: %year%, %monthnum%, %day%, %hour%, %minute%, %second%, %post_id%

    I repeat: Even something like /site/%postname%/ won’t work as the regex checks the first structure tag and does not care about any static prefix.

    [I apologize for this long comment and hope to clear things up. May I even be so keen as to ask the author to clarify his penultimate paragraph accordingly? (Where it says Leave a number, or something static, at the beginning of your permalink string and you’ll never have any sort of problems.) TIA]

    • I’ve made a note of that several times in these comments already.

      Also, WordPress 3.1 fixes that particular issue. A static string at the beginning does prevent use_verbose_page_rules from being enabled in 3.1.

      So yes, /static/%postname%/ will work fine in 3.1.

      • Thank you for getting back to this so quickly. It was due to the paginated comments that I must have missed your note. As much as I am sorry for that it may be a sign it is indeed worth mentioning in the main article ;) As long as 3.0 is “official”, that is. Plus your article is referenced by the WP documentation :) Anyways thanks for all your efforts. This very article is the only concise info on that topic.

        Happy 3rd Advent!

      • How do you set up something like /static/%postname%? I set my custom structure to ‘/heating-and-air/%postname%’ and it made no change. Do I need to edit the rewrite.php file Ben mentioned above?

        Running WordPress 3.1

      • Hello Otto and thanks for your post.

        One thing, what about custom posts?
        Imagine a custom post called “custom” where the urls are /custom/%postname%/. How does this work?

        Is that /custom/ considered as the /static/ you are saying here or is not since the /custom/ is added by the custom post itself?

        Thanks and regards

      • Based on my testing, this is not functioning in 3.1. My permalink structure is set to ‘/news/%postname%’ and it is still generating verbose rules. I have tried resetting it multiple times, and putting the %post_id% in the first position eliminates the verbose rules. Is anyone else encountering the same issue?

      • I have gotten to 250+ pages on my site (I’m documenting stuff which is hierarchical in nature, so everything gets a page) and was definitely seeing site slowdowns, so this article cleared up that mystery – I had indeed gone with /category/postname as per instructions I’d seen somewhere online.

        So I tried /index.php/%postname%/ to see if it eliminated the use of rewrite rules (per https://codex.wordpress.org/Using_Permalinks#Permalinks_without_mod_rewrite). It did speed things up immediately, but I saw that it put /index.php/ in the permalink, so I changed it to just /index/ as I wanted to test a plain static link and thought that if it worked, /index/ would look better.

        However, now /index/ does not show up at all, it just has domain/postname in the permalink. Which works fine for me, esp. since it’s showing domain/parent/child page names as it goes down the structure. So I have exactly what I need for page permalinks and apparently without any performance hits. I guess it’s true, being lucky is sometimes better than being good :)

        • Clarification – after installing the AskApache plugin, I see that verbose page rules were still on :( no idea why it seemed faster then.

          I then went with /%post_id%/%postname%/, and I see that verbose page rules are off now. And, the permalinks are still pretty and parent/child hierarchical. No page ID is showing up in the link.

          Not what I expected, but hey, I’ll take it.

  3. Have a concern about a Premium Theme I purchased to run a directory website. It states that the permalink settings should be set to %category%/%postname%. I e-mailed sales before purchase and was assured that this was OK but have read otherwise for a while now. My directory contains over 4,000 listing members. Which in this case of an import will make for 4,000 pages plus. Is it a good idea to run a directory from WordPress as I want (pretty urls as a sales feature) or should I look for other solutions?

  4. I have the following setup:

    /%post-id%-%postname%.html

    and for categories and tags

    nl
    tag

    This works fine except with the menu structure I have a nested page (for instance, customersupport > warranty) goes out of control.. how can I fix this?

  5. Hi Otto,
    I have been reading thru this thread and am still unclear on how I should proceed. I have a blog and membership site. At the moment, I have over 100 pages, and will be adding even more as I produce more content. Can you please advise me how to structure my permalinks for best SEO results, while not crashing my site as it gets bigger. From what I read, it looks like putting a static placeholder- like %year%%postmane% will work? I am running WP3.0.3
    Thanks

  6. Otto,

    Thank you for this thread. It has helped me a lot.

    I have set my Permalinks Settings as you suggested (year, month,title).

    I have 12 pages (not posts) already set up with the Permalinks showing only the page title.

    Will that work OK for the static pages?

    thanks,

    Tom

  7. Ok, so if i add /news/%postname%.php on all my posts i should be fine in WP 3.1. Can anyone help me with a rewrite in htaccess to point all posts with %postname%.php to /news/%postname%/ instead?

    BR,
    Johan

  8. […] Category in Permalinks Considered Harmful Firstly, it’s really not any better for SEO to have the category in there, or to have just the postname there by itself. And anybody who tells you differently is wrong. If you disagree with me, then no, I’m not interested in arguing this point with you; you’re just wrong, period, end of discussion.” […]

  9. How about /%category%/%post_id% then? Will it add unlimited rules or only one for each category I use? Because I like this structure and I only have 4 categories.

  10. I know this would make for a fairly long url, but I want to include the category name and post name as well, while not being subjected to the verbose handling.

    So, would /static/%category%/%postname%/ be alright? My Category names are not long, but could help with longtail searches.

    Do you agree?

  11. […] want it :( i ended up googling for some information and the manual page landed me on this page too otto’s thought about permalink, otto makes a quite good explanation on how the algorithm works, and recommend to not use […]

  12. Thanks Otto, Fortunately this is not my problem at the moment, but an excellent read will pass this on.

  13. I like placing my link at the bottom of a posting for further reference or whatever. Now I purchased a software that provide content to my blog and have been unsuccessful at placing my link after the software pre-loads my blogs with content. My question is where do I place a link outside of using permalink or should I just be content with the unique domain name. Is there some other setting in which I can go under to manage placing a link (such as an affiliate link) a possible prospect may click on after reading my rich content blog. At this juncture, any suggestion would be appreciated. Sincerely, Mary.

  14. Hi All. After pasting some given code in my functions.php file /category/ is no more there in my category urls.
    previous: blog.com/category/videos
    now after using code in functions.php: blog.com/videos
    My permalink structure is set to /%category%/%postname%/. I will have about 30-50 categories in my blog to work with. Any suggestions about my permalinks structure will be handy.

  15. Im not making a blog and i cant believe that i cant use /category/postname. No i dont underestand your complicated, or unclomplicated logic for it not to work. Im currently left with /browse/category-name for category base but for posts i got no base and just /post-name. please understand that this looks ridiculous.. if you know how i can set a post base or if i can fix wp to accept /category/post-name i would be delighted for any insights here! Thanks.

  16. This post is quite useful for beginners as well as experts of WP.

    I have a question if i want to make a portal in WP, can i do so, are creating multiple pages limit the performance of my WP. So should i use Post rather than using pages and if so what will be the difference of using post and pages.

  17. […] Category in Permalinks Considered Harmful » Otto on WordPress By six, on November 29th, 2010 Category in Permalinks Considered Harmful » Otto on WordPress. […]

  18. As I posted several months ago, if I use one of the recommended strings like “%year%/%postname%” or “/%year%%monthnum%/%postname%” my posts do not come up. The following message is displayed:

    “The page isn’t redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete.”

    I do have Dean’s Permalinks Migration plugin installed.

    On the other hand, if I use one of the strings that should not be used, like “/%category%/%postname%/” or just “/%postname%/” things work fine.

    • OK, I set it up as “/%post_id%/%postname%” AND deactivated the Dean’s Permalink Migration plugin. Seems to work fine now. All posts going back to the beginning 4 years ago display fine.

      As this string starts with a number I think I will leave it as is and get rid of Dean’s plugin. Years ago even with the “%category%/%postname%” string, if I did not have DPM activated my posts would not display. Now the work only if that plugin is off. Maybe something changed in the latest versions of WordPress?

      Anyway thanks again for this post and your patience with some of us!

  19. So, if I want to switch from /%category%/%postname% to /%post_id%/%postname% for my blog with 800 posts/pages… how do I proceed so that links from external sites don’t break? And what do I do about the search engines?

    Thanks in advance.

    • Is there a tool that can automate creating a list of 301 redirects for my .htaccess file?

      • Checkout the Redirection plugin. I’ve used it with success in the past.

      • Just that I’ve just changed my permalinks to /%year%/%postname%/ from /%year%/%month%/%day%/%postname% – I was looking around for 301 redirect solutions and/or manual modifications to .htaccess. Many of the redirect plugins were quite extensive and seemed prone to break sites too, at least from much of the feedback and help posts I was reading. So I was not really wanting to go that route.

        But during some testing what I’m seeing is that WP is automatically doing 301 redirects from the old permalinks to the new ones. Running WP 3.0.4 – is this perhaps a newer feature of WP? Or perhaps its been able for some versions to handle this type of internal permalink change and generate the redirects.

        • That’s one of my question. I’m running 3.0.5 and I want to change the permalink structure and want to make sure that redirection will work. I’ve seen many plugin to deal with older version but no indication if newer 3.x branch support that by itself. I’m just afraid to press the button and having to deal with the mess after so before pressing the button I try to find an answer.

          Some are discussing 3.1? Any change regarding permalink? If release is not too far, worth the wait?

  20. I have over 10,000 posts so far before launching my site, so I obviously want to pick a good permalink structure, which now is just /%postname%. I have seen a lot of people use /%post_id%/%postname%. I would rather not add that extra level of depth to my permalinks. I would rather just hyphenate the two as /%post_id%-%postname%. How will this impact the performance relative to the two other options?

  21. […] but this is clearly stated in the WordPress Permalink Documentation, and there’s a great technical write up on this issue by […]

  22. I recently switched to using /posts/%postname%/ on my blog from /%year%/%postname%/, but had to change it after discovering that it changes the urls for my categories and tags also.

    It went from http://www.crimemysterybooks.com/category/some-category to http://www.crimemysterybooks.com/posts/category/some-category.

    Do you (or anyone) know why this happens and if I can get around it? I really liked using the static component in the url versus the date but I don’t really want it to mess with my urls for categories and tags that way. If I can’t find a solution, I might use it anyway, but it messes with me when I’m creating links to my category and tag pages from memory because I always forget that it puts the /posts/ in front of them.

    • Sorry! I also didn’t mention that this of course creates a bunch of broken links from my old category and tag page links because I tested it and WordPress wasn’t redirecting to the new /posts/category/some-category from /category/some-category

      I don’t understand why this creates that additional element in the url when %year% doesn’t.

      • @Terescia – looks like you’ve changed to using a static string, “/posts/”, in your permalinks and that’s going to be in all of the generated permalinks. You are telling WP to include that, and there isn’t a way for WP to determine not to. When using “/%year%/” or the like then WP can determine not to use it for a /category/ link (or the like) since the entire permalink sting is programatically determined. Once you put static strings as part of the link then I’m fairly sure those will always appear.

  23. […] Codex – Using PermalinkWordPress Trac – Optimize Rewrite Rule GenerationCategory in Permalinks Considered Harmful Leave a Reply Click here to cancel […]

  24. Hi,

    Thanks for the post, finally this is the first answer to the question raised in my mind about what EXACTLY is the problem with using categories in permalinks.. however I think till I have a very few static pages (2-3), it should work fine.

  25. Hi,

    Thanks for the post, finally this is the first answer to the question raised in my mind about what EXACTLY is the problem with using categories in permalinks.. however I think till I have a very few static pages (2-3), it should work fine.

    P.S: the point about the SEO advantages actually are not proven and I cannot see any linked reference here.. on the other hand having the category names in the links help me to track the traffic coming for different sections, thus I can see how posts about ‘travel-planning’ works vs. ‘travel-news’.

  26. […] There is a good explanation in detail on how this works and why it is harmful. […]

  27. […] it because it is unfriendly to users in the many contexts in which users interact with URLs.) See Otto’s technical writeup on the topic as well as this wp-testers […]

  28. […] it because it is unfriendly to users in the many contexts in which users interact with URLs.) See Otto’s technical writeup on the topic as well as this wp-testers […]

  29. […] it because it is unfriendly to users in the many contexts in which users interact with URLs.) See Otto’s technical writeup on the topic as well as this wp-testers […]

  30. […] know WHICH page you wanted? Simple enough. For details on that, you can read Otto’s post on Category in Permalinks Considered Harmful.When you add in MultiSite, suddenly the code has to check for something more: is this new Site […]

  31. Otto is so wrong with category not being beneficial for SEO, why is this post considered somehow valid?

    Proof: Go to google.com search “windows” – see that the first URL that comes up at the time of the writing http://www.microsoft.com/windows/default.aspx has the “windows” part highlighted with bold. Then check out the multitude of other URL-s having the relevant parts bolded for emphasis. Do you need anymore?

    And he is wrong about category being problematic by itself, the problem is not having a numeric value in front of the pretty permalinks address/chain. Just add month of the year in front of it – it only has double digit values and has the lowest number of different double digit values. Then put category/postname. So the best way is to use month/category/postname

    Why such a strong tone when you are wrong, Otto?

    It could be be bad use of NLP and copywriting, because you are certainly incorrect, just trying to sound like a man, this is bad for WordPress for having people who do not know a lot being the power users – phoney in a word!

  32. […] ottopress.com/2010/category-in-permalinks-considered-harmful […]

  33. My site has over 50 pages, no posts. My permalink structure is:

    /%year%/%monthnum%/%day%/%postname%/.

    Page URLs don’t show the year, month or date though, just the page slugs. Is this setup not bad? Should I be best making plans to switch the permalink structure to default?

  34. […] technical reasons behind why 1 & 2 are important can be found here. In a nutshell, WordPress doesn’t have to work so hard to work things out. […]

  35. […] and WordPress developers/enthusiasts over what the best structure actually is. After reading Otto’s explanation of the performance issues involved, I’ve decided to change my permalink structure from: […]

  36. Very interesting post — don’t use %postname%, %category%, %tag%, or %author% at the beginning of permalinks. Especially for multi-site and large blogs/sites. I’m going to use %year% from here on out. Thanks, Otto, for the research involved and for posting this!

  37. Just curious – would this still be an issue if using something like the plugin: W3 Total Cache. Would a caching plugin circumvent this problem? Also – any idea if a fix to this is coming out?

    • This isn’t really a bug, so there’s no fix for it coming out anytime soon. It’s a basic design decision with how the URL Rewrites have to work. See, a number is a number and easily recognizable as such. Alphabetic characters, on the other hand, can be anything. How do you recognize “example” as a category or a post name or what have you? The URL Rewrite system doesn’t make database queries to figure it out, it works on the set of rules given to it, and those four (category, post-name, etc) can be anything at all.

      So given a URL like http://example.com/demo/something, you have to have a set of rules that can match against it and determine that “demo” = category and “something” = postname. But, “/demo/something” could also be a page name, since Pages live at the top level of the URL hierarchy. So, if your ruleset allows for that first match to be anything, then the Pages, which can also be anything, need to be explicitly defined so as to allow for a match.

      Thus, having something at the beginning of your custom permalink string which cannot be anything (like year, which can only be a number), allows for your rules for Pages to not need to be explicitly defined. If anything other than a number appears there (ignoring your tag/category/taxonomy bases), then that means it’s a Page that is being requested, and the query variables can be set appropriately.

      Caching plugins don’t solve the underlying issue, which is that with a too broad matching custom permalink rule and a large number of Pages, your ruleset can grow too large to handle in a reasonable execution time. Best way to solve it is simply to make the URL structure capable of recognizing types of things without having to have an excessive ruleset… and that means using something easily recognized at the beginning of the custom permalink string, like a number or some static text.

      • Hey Otto,

        I’ve been following this thread for quite a while. Thanks for posting the great info. I must admit that my website is in crisis do to my initial ignorance (est. 2008).

        I’ve set my permalinks as /archives/%postname%/ and was hoping that 3.1 would fix that. You are mentioning that “this issue” – verbose rewrite rules – won’t be solved anytime soon, because it’s not a bug, but rather its engineered by design <– I must agree, despite being on the short end of the stick. Do you think they plan to change at least the ability to add static /something/%postname%/ within months, or I shouldn't hold my breath?

        My site got to the point where I had to double the cost of my VPS (still timing out), I can't post or edit PAGES, but can post and edit POSTS (after deleting all revisions <– good temporary fix for all of you with tons of pages). I use a Local WAMP Server to modify pages, but it's becoming a true pain in the… Time to change the permalink structure or hold my breath a few/several more months?

  38. Otto,

    Does it matter if you use a “hyphen” or “forward slash” to separate the fields?

    For example, are both of these equally good?
    %post_id%-%postname%
    %post_id%/%postname%

    • I have also wondered about this, because I distinctly remember the permalinks page in the WP official docs recommending %postname%-%post_id%. (Yes, in that order.)

      /checks – Yup, I saved the quote.

      http://codex.wordpress.org/Using_Permalinks (once said)

      “If you want to list your site in Google News, one of the requirements is to have at least three digit identifier at the end of every url.

      This is easily accomplished using %postname%-%post_id% structure, which will append post ID to the end of URL so it becomes http://example.com/cooking-tips-tricks-344.”

      • Well, it may have once said that, but it doesn’t now.

        The Codex is a wiki. Anybody can edit it. So the information there should be taken with a grain of salt.

        • Mini-rant incoming. Please don’t think it’s directed at you personally. I’m just feeling a tad frustrated about this issue atm, and want to let off some steam.

          I only realized it was a wiki when I found out about the performance problem. Honestly, I wouldn’t have started with postname (on a couple of my sites) had that (very official-looking) page on WordPress.org not suggested it. I also remember the Pretty Permalinks page/section practically bashing just sticking with “ugly” links. This was, I think, 2-3 years ago.

          Mind you, my affected WP sites are small (less than 10 pages each with about a dozen posts each) so I don’t get hit with performance problems much, but this still worries me. I’ve been keeping track of it for nearly a year, hoping it would be fixed. Plus, my attempts to fix it have not panned out.

          On one of my sites, I tested changing the permalinks back to UGLY, but then all the links indexed by Google, etc. become 404’s. I tried fixing it with the Redirection plugin, but it gave me an error-saying that Permalinks have to be enabled. Had to switch back.

          /end TLDR

          • With the amount of pages you have, you might be able to wait for the solution without taking a huge hit from the performance perspective. If you plan to add several hundred posts/pages, you would still be ok, although your page/post edit/add-new dashboard may become slower. Also, the number of requests to the server would increase, but it would be manageable, for sure.

            I have several established websites that use some sort of the “wrong” permalink structure. I can tell you that when you reach 1000 – 2000 pages/posts, you’ll definitely start seeing the slowness on both the website and the administrative end. For me, when I got over the 2000 threshold I couldn’t add/edit any more pages (I had 90% pages and 10% blog posts). The site would crash after hitting the Publish/Update button.

            Moral of the story: if you have or plan to have a 100-500 pages/posts using WP as a CMS or a blog, you will be just fine. Anything over, you may get some trouble. I just wouldn’t worry about this and I would keep the pretty permalinks, especially if you plan to have a small # of pages.

            My live “experiment” was on both shared hosting and a VPS — both were Hostgator hosted + I was using the /%postname%/ permalink setting. I left one of them as is and I switched one of them to /%post_id%/%postname%/ – the switch was a life saver. The site doesn’t time out and everything loads much quicker on both the user and admin end. Hope this helps.

            • Thank you for the reassuring post. (You were trying to be reassuring, right? :P)

              I’m okay with it mostly. Just a bit annoyed, especially with Google pressuring people to make light-weight sites.

              • Of course, reassuring. You’ll be just fine in my opinion, unless you use sub-par hosting. You can also use a caching plugin to ease the load on your server and save users time loading pages.

                • I am using W3 Total Cache though just for Minifying. I used its CDN feature but something went terribly wrong. The error_log ballooned, actually dwarfed the entire WP site, and a ridiculous number of requests was sent to Amazon S3. But, of course, that’s another story entirely.

            • While researching this I found Msieur Dubois’ plugin which seems to address the admin update side of the issue – http://www.yann.com/en/wp-plugins/yd-fast-page-update. Perhaps it would help you with your crashing sites?

              There is a strong disclaimer that things may go wrong though, it’s a .2 version. But if a site is going down anyways, maybe it’s worth a look.

      • @Heidi,
        I think the structure would have to be left to right like …

        %year%/%postname%-%post_id%

        … to have the few digits number “at the end of the URL” for google news inclusion. I remember that too, from somewhere.

        @Otto, lovely post. I am also one of those /%post%.html people :) but so far it’s not slow. Would love to fix it somehow though, what is the appropriate way to change to something correct like /%post_id%/%postname%.html , do you know of something you could suggest/descrive??? A post only on the fix would be needed perhaps for many people. Thank you Mate. r

        • Sorry one more thing, no one is talking about the slash “/” at the end of the url structure. Do the permalinks work the same way no matter whether there is the “/” at the end or it’s without it???

          E.g.: /%post_id%/%postname% versus /%post_id%/%postname%/

          Honestly if all right I’d prefer to have it only /%post_id%/%postname%

    • The dash doesn’t make any difference, although it looks weird.

  39. Using the Ask-Apache rules viewer plugin, I see that verbose page rules are on and that I do have a lot of rules (over 2800 page rewrite rules and over 2900 wp rewrite rules, wow).
    So here’s the obvious question – once you’ve changed the page permalink structure to something safe, how do you turn off / get rid of the old rules that are clogging up the works?

  40. I’m useing /post/%postname%/ for my Permalink links. Will I run into issues there?

  41. The other thing, is /post/%post_id% bad as well?

  42. Wow! I’m floored, I didn’t realize that this simple change could make such a difference in the performance of a blog. So thank you! But I am now in a quandary. My site has close to 500 posts and they have the /%permalink%/ structure…what plugin or code can I put in my .htaccess that will automatically redirect any link building I”ve done for this this site. Anyone have any tips?

    • From what I know, this problem depends more on the number of pages in your site, rather than the number of posts.

      If you’ve got less than 30 pages, (I think) it’s not a huge problem.

      But yeah, it’s still a bother. I’ve come across folks suggesting changing the permalink structure and installing the Redirection plugin, but I haven’t successfully done so myself.

  43. Hi Otto, thanks for the insightful post.
    I installed the AskApache rewriterules viewer and checked the difference on a new install, with abou8 test pages and a few posts.

    When switching from one of the ‘allowed’ permalinks formats to one of the ‘frowned-upon’ ones, the Page Rewrite indeed went from 11 to 88 rules, 11 per page.
    But what is strange is that every set of 11 rules is exactly the same, no reference to page ID etc.

    So is it not just a bug in WP, that all these rules are created, as it is just a repeat of the same rules, which should not change anything but add serverload?

    I welcome your thoughts
    Cheers, Harry

    • ps: also the wp-rewrite rules increased with the same amount, but also here it just duplicates existing rules. Is this a bug or am I misunderstanding how this should work? Thanks for any insight.

    • Those rules aren’t exactly the same nor duplicated. Perhaps the plugin is showing you something wrong or you’re misreading it, but the 11 rules it generates per page all start with the page’s slug, which is different for each page.

  44. Double-posted. Please delete one of them. I was trying to reply to Daniel but my reply doesn’t seem to thread under his post.

    I have more questions, hopefully not too noobish.

    I have to add new content to a use_verbose_page_rules impaired WP install. It’s better to just add a new post, rather than a new page, right?

    Also, would adding a new post make the performance problem worse? Or is it just adding new pages which makes it worse?

    Conversely, would decreasing/consolidating the number of pages and/or posts make it better?

  45. […] Best WordPress Permalink Structure For Scaling, Performance and SEO via WPMU.org Category in Permalinks Considered Harmful via Otto on WordPress Optimizing WordPress Permalinks via Digging into […]

  46. This might be a dumb question, but please clarify. When you say “number of pages,” you’re just referring to content created under PAGES ->ADD NEW -correct?

    For example–I use posts for all of my content–The posts are acessible through the category menu–The only pages I’ve created are “about” and “contact” pages. So should I be ok? There’s nothing else on a WP blog that’s counted as “pages” is there?

    Thanks

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Need to post PHP code? Wrap it in [php] and [/php] tags.