Redirect old permalinks to new permalinks

I changed the permalink structure from /%category%/%postname%/ to /%year%/%monthnum%/%postname%//

How can I redirect all old posts to the new ones (eg: via htaccess)?

Related posts

Leave a Reply

2 comments

  1. WordPress should handle the 301 redirects for you automatically in this case. It doesn’t always, but it should here.

    Long story short, WordPress has a function, redirect_guess_404_permalink which tries to find the correct post when it encounters a 404 by using the end of the 404 url to query against the wp_posts.post_name. If it finds a post, it will perform a 301 redirect. In your particular case, because your old structure ends in %postname%, this should very reliably 301 all your old paths.

  2. You can also redirect via WP. Yes, the htaccess variant is with better performance, but a small plugin is easy to use.

    Use the Hook template_redirect and check for the conditional function is_404(); if true, than get the right permalink and rewrite. Also you can use the small plugin Change Permalink Helper.