WordPress Hack #12: Changing Permalink Structure Seamlessly

Posted by jtpratt |01 May 08 | 26 comments

Ever wanted to change your WordPress permalink structure but were afraid of 404 errors and SEO problems? I have a WordPress Hack to fix all your problems right here!

This is installment #12 of 30 WordPress Hacks in 30 Days!

This WordPress hack is one that I planned on writing write after the last one about rotating and recycling posts out of your archives and on to your home page. Mainly because there is one thing I didn’t address before, and that’s you permalink structure. In WordPress your “permalink” structure is your URL. By traditional default WordPress blogs have a day, month, year structure to the URL like this:

www.site.com/05/01/2008/my-new-post

In your WordPress dashboard in either settings (WP 2.5) or options (before WP 2.5) -> “Permalinks” you have the ability to change the structure to whatever you want. In the beginning (because they don’t know any better) most people don’t and leave the date default. Even Matt Cutts says don’t use post dates in URL’s. Why not?

WordPress Hack #10 should have been a prime example – if you’re going to be recycling your old posts to the home page, it’s going to change the published date to the current day – right? Well, it won’t change the permalink (URL) – and it will still reflect the old date. You could change the permalink structure manually in your dashboard, but that would just create new URL’s for every single post (removing the date portion), so every single bookmark and every single search engine listing you ever had will now be an “Error 404″ page. Ouch!

Over time if you write new posts every day or every week you probably aren’t going to want the post dates to matter as much, since new readers will be coming on board all the time. In addition – maybe you’ll want to move out of WordPress to another blogging platform someday that doesn’t have a date based post convention. If you’re in the same boat I was, you are now in quite the predicament – what to do, what to do?? Once again, enter a lifesaver WordPress plugin “Dean’s Permalink Migration!” It’s very simple to use, and will solve all your permalink problems.

First install and enable the plugin. Then in options or settings -> “PermalinksMigration” in your WordPress dashboard you’ll see a simple text field for only one option:

permalinks migration options

All you have to do is enter your OLD permalinks structure in that field. For most of you that’s going to be:

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

What I did was open up two tabs in my browser, both with my WP dashboard open. In one tab I had settings -> Permalinks and the other settings -> “PermalinksMigration”. I just copied and pasted my “permalinks” structure to “permalinksMigration”. Then in “permalinks” I changed the structure from this:

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

to this:

/%postname%/

Then I click “update” to save each tab, one immediately after the other. To recap- what I’ve done here is removed the dates from my permalink (URL) structure, and the “Dean’s Permalink Migration” knows what my “old” structure was, and it will automatically redirect each and every page using old date based structure to the new page. You won’t lose any hits from bookmarks or search engines at all, and all of your URL’s will be much cleaner and shorter from now on.

The ONLY drawback I could think of was, this plugin only works ONE TIME. Since it only has one field for previous permalink structure to redirect – it can only redirect the last change you made. Hint to the plugin auther, you could hack this plugin to allow for multiple changes, and adding the ability to do the same for category permalinks would be a boon too!

Now I can just hear somebody screaming from the back of the room “what about my pagerank, what about my pagerank!”. In effect, to search engines, indexers, and crawlers this should be the same as a 301 permanent redirect. If you had pagerank assigned to any of your individual posts, it should transfer to the new URL over time – typically from a few weeks to a few months depending on google’s update schedule. I personally really don’t worry about pagerank anymore at all – you probably shouldn’t either.

I hope that this hack helped you as much as it helped me once found it. If you have any comments to make this post better, or question – please comment now!


26 Responses

  • Make Money Online Blogging/ 01 May 08 @ 3:32 PM

    Nice hack, but as long as you are familiar with wordpress, it shouldn’t be an issue. Either that or for lazy people.

    Shudogg Dot Com – Make Money Online Blogging

    Make Money Online Bloggings last blog post..Adsense Secrets Volume 4

  • admin/ 01 May 08 @ 6:00 PM

    it doesn’t matter how familiar you are with WordPress, if you change your WordPress permalinks without this plugin you screw up all your search listings and anyone who clicks on one or uses a bookmark with get a 404 error. There is no convention in WordPress to accomodate for changing permalink structure and redirecting the old URL’s to the new structure. It has nothing to do with being lazy.

    If you were familiar with WordPress, you’d know that when you make a comment, you don’t have to include a link back to your site in the comment, because you automatically get one at the top of your comment. Since I have CommentLuv installed you even get a link back to your last post in your RSS feed!

  • Acupuncture/ 02 May 08 @ 11:17 AM

    I’m happy I learned about permalinks before starting any WordPress sites!!!!

    I dead a ton of reading on it. There are all kinds of opinions. I ended with domain/%postname%/ only. For the very reasons JT talks about. I didn’t want to end up having to redirect everything at some future point. The one knock I heard about this permalink structure is, it slows down the database?!?!?! I have no idea if that is true. The person stated it on a forum and insited that an ID must be put with it. Well, after viewing tons of WordPress sites that rank well I noticed they didn’t bother with the ID. . . maybe I’ll end up with a slow database. . . don’t know but I would think this issue would have been brought up to the WP programmers.

    Charles

  • DR/ 02 Jun 08 @ 7:21 AM

    Quick question: When I change the permalink structure on my WordPress 2.5 blog to /%category%/%postname%/, the old posts’ url doesn’t change. The links seem to all work, but the url stays the same. What am I missing?

    DRs last blog post..Make Money Blogging–Setting Up a WordPress Blog in 3 Easy Steps

  • admin/ 02 Jun 08 @ 8:12 PM

    @DR – I’m not sure what you mean. You changed your permalink structure and the URL’s stayed the same – have you enabled the permalink migration plugin?

  • How To: Making Your Old WordPress Posts New Again/ 11 Aug 08 @ 1:01 AM

    [...] your posts doesn’t change when the old posts are “shifted” to the home page. Read How to change permalink structure seamlessly if that situation applies to you. Want automatic updates? Subscribe to our RSS feed or Get [...]

  • Jason/ 08 Sep 08 @ 2:40 AM

    Do you know if you can change the page urls. I can change the permalink post structure but I want pages to end in .html. Well, a client does. I’m a bit stuck. =|8

    Any ideas?

    Thanks

    Jason

    Jasons last blog post..Heavyweight pages

  • admin/ 08 Sep 08 @ 7:36 AM

    @Jason – first of all, tell your client that he’s nuts, and in today’s day and age there’s no reason to have any page end in “.html” because google just doesn’t care. I mean, come on – google can even index flash files now. That’s like giving someone a piece of bread, and telling them to call it’s a “biscuit”. They don’t care what you call it – they know when they’re eating it it’s still a piece of bread.

    In any event, if you client still insists on being a stubborn little know-it-all…you can still do this. Just change your permalink from /%postname%/ to /%postname%.html and I believe that should do it!

  • Jason/ 08 Sep 08 @ 7:40 AM

    Oh Yes He knows he is nuts! I tell him daily. = That hack fixes the posts but bizarrely not the pages.

    Maybe I’ll have to play with the htaccess file.

    If I find the answer I’ll post it!

    Jason

    Jasons last blog post..The great social marketing experiment – Part 1 – The beginning

  • swanky gift ideas/ 08 Sep 08 @ 2:45 PM

    Great post, I am been looking for articles about this.

    swanky gift ideass last blog post..3 Badass New Terran Gameplay Videos For Starcraft 2

  • trumank girls/ 17 Sep 08 @ 2:09 PM

    = wow i have a lot old post .. this tutorial is great thanks

  • Chad/ 06 Oct 08 @ 4:16 PM

    What about the codex part that says you shouldn’t use just /%post-name%

    Is that still gonna be a problem?

    Chads last blog post..Webcam Visuals

  • admin/ 07 Oct 08 @ 11:30 AM

    @Chad – personally I think that paragraph is a ridiculously old and outdated piece of information that should be removed. It even questions itself with the (is this true with WP 2.0+) mention within it. It was written way back in the days of WP 1.x.

    About 2 years Matt Cutts wrote a post saying that WordPress sites should “drop” the date based permalinks and to postname only after the URL because it was better for SEO, and better if you (later) restructure your blog or site. I have to say – he gave great advice, it’s been working for me.

  • Dudu/ 10 Oct 08 @ 8:30 PM

    Do you known if there’s a way of using %tag%/%postname%/ as a permalink without breaking WordPress?

    Dudus last blog post..Vem aí o Rolls-Royce de pobre

  • admin/ 13 Oct 08 @ 8:24 AM

    @Dudu – no I don’t know of anyway to do that and not break wordpress. Especially because a post could have multiple tags. Why would you want to do this?

  • Dudu/ 13 Oct 08 @ 12:54 PM

    I was thinking about it because tags usually have more identification with the content than the category – that’s normally more generic.
    And a post can have more than one category too.
    Maybe WordPress should have one option where we could set one tag as the most important and it could be used in the permalink.

    Dudus last blog post..Paulo Lins é um spammer dos piores

  • admin/ 14 Oct 08 @ 8:03 AM

    @Dudu – Maybe you misunderstand how tags and categories work. Each tag has it’s own page, and each category has it’s own page, and posts (in those tags and categories) are listed on their assigned pages. It would be redundant to have /%tag%/%postname%

    Also, ever tag and category assigned is usually listed in the meta of the post, it would be of no use to have it in the URL, and of very little use SEO wise.

  • Dudu/ 15 Oct 08 @ 8:35 PM

    I was thinking that maybe it could be better (SEO speaking) to use a tag in the permalink.
    But maybe you’re right.
    Anyway, thanks for you’re answer.

    Dudus last blog post..Passagens Gol com milhas do programa Smiles

  • How To: Making Your Old WordPress Posts New Again/ 29 Oct 08 @ 2:39 PM

    [...] your posts doesn’t change when the old posts are “shifted” to the home page. Read How to change permalink structure seamlessly if that situation applies to [...]

  • Chris at prepaid cell phones/ 31 Dec 08 @ 12:10 AM

    Great point about post dates. It seems like the best idea is to leave them out of the URL–even though I still include them on one site I run. But it makes sense to not have the dates there and instead just have the keywords from your post title. Much cleaner looking too.

    Chris at prepaid cell phoness last blog post..Get a Free Cell Phone Headset Online

  • Shane/ 12 Feb 09 @ 12:28 PM

    Glad I ran across this post. I’ve been contemplating changing my permalink structure from /%postname% to /%year%/%monthnum%/%postname% but I’m not so sure I’ll be doing that anymore.

    Shanes last blog post..Wii Fit is Awesome

  • Chris @ Driving Spirit/ 02 Jun 09 @ 1:57 AM

    What a great tip! I’ve been wanting to do this for a while now, having started off my blog with the year/month URL.

    Downloaded the plugin, installed, followed your instructions and it worked. Permalinks changed and redirected in a couple of minutes!

    I wish I’d found out about this a few months ago.

    Chris @ Driving Spirits last blog post..20% Off Osram Nightbreaker Headlight Bulbs

  • Private school guy/ 03 Jun 09 @ 10:22 AM

    Dean admits on his blog that his plugin does not work for redirects from ?p=#. Wouldnchaknowit. Anybody know a way around this?

  • Phil/ 01 Jul 09 @ 4:47 PM

    “Dean admits on his blog that his plugin does not work for redirects from ?p=#. Wouldnchaknowit. Anybody know a way around this?”

    I have tried dean’s and a couple more plugins without success, edited the .htaccess file and still cannot change my permalinks structure. Could it be WP backend or server config side?

    I wouldnt of thought it would be this fiddly.

    Anyone have thoughts or work around?

    Cheers,

    Phil
    .-= Phil´s last blog ..Microsoft Pushes IE8 With Ads that are Actually Funny =-.

  • Randy/ 09 Oct 09 @ 3:27 PM

    this looks great!

    Does it matter which ORDER you UPDATE the permalinks and the migration?

    also I found a post that says this plugin creates a vulnerability and supplies a plugin (called 1.1-gx) to stop that vulnerability. Is it worth putting in the extra plugin or not?

  • admin/ 13 Oct 09 @ 10:51 AM

    I don’t think it matters what order. I don’t know about the vulnerability – I no longer use this plugin personally since I changed my permalink structure years ago.

You must be logged in to post a comment.