WordPress.org

Ready to get started?Download WordPress

Forums

permalink change via .htaccess (9 posts)

  1. btard
    Member
    Posted 6 years ago #

    my blog is set up with the following permalink structure: /%category%/%monthnum%/%year%/%postname%/

    I would like to change it to this standard structure: /%year%/%monthnum%/%day%/%postname%/

    does anyone a regexp expert and could help me with this?

    also, I have a blog with the traditional domain.com/?p=84 setup. I would like to also convert that to /%year%/%monthnum%/%day%/%postname%/

    I suck at regexp. I have tried, I am not looking for a solution, just help or an idea on how to proceed.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Why would you need to know regexp? Just change the options in the Options->Permalinks screen.

    Make sure you're running the latest WordPress (2.3.2) before you make the change. Later versions of WordPress remember old permalink settings and redirect to the new permalink addresses.

  3. btard
    Member
    Posted 6 years ago #

    because I have a lot of posts that I would want to permanently move via a 301 redirect.

    currently I added a bunch of explicit rules for specific pages that I get a lot of traffic from but I think I need to match the pattern instead. any ideas?

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    because I have a lot of posts that I would want to permanently move via a 301 redirect.

    Again, I reiterate: "Later versions of WordPress remember old permalink settings and redirect to the new permalink addresses." Yes, as in a 301 redirect.

    Changing permalinks means that the old permalinks will now send 301's to the new permalinks. No need for any .htaccess changes. This is built into WordPress. As of version 2.3 or so, I think.

  5. btard
    Member
    Posted 6 years ago #

    holy cow thats huge, how the heck did I miss that?

  6. btard
    Member
    Posted 6 years ago #

    ummm, weird. it didn't seem to work.

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Well, change it back then. It should have worked, but no harm, no foul.

    Looking through the code, I see that perhaps I'm confused. I see that it remembers old slugs, and that it will do canonical redirection as well if the link is slightly off (www instead of non-www) and that it will even attempt to guess if it can figure out what is the post_name. But it doesn't check old permalink settings like I thought it did.

    I think that yours would have worked if you didn't switch the position of the year with the day. Oh well. Lemme look at it some more.

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Here's a plugin designed for this sort of thing:
    http://scott.yang.id.au/code/permalink-redirect/

    It has an option called "permalink_redirect_oldstruct" which lets you put in the old structure to have it redirect when needed. I'd try that.

  9. btard
    Member
    Posted 6 years ago #

    weird, it's all working on both sites: nostatus.com and blog.movieset.com. so awesome. nostatus i managed to fix the redirect and movieset has the old posts being 301';d to the new domain etc.

    thanks for the assistance ottoman :)

Topic Closed

This topic has been closed to new replies.

About this Topic