Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

A few years ago this was the permalink structure I had for my blog:

/%year%/%category%/%postname%.html

I changed these permalinks last year to this:

/%category%/%postname%/%post_id%/

A plugin that goes by the name Permalinks Redirect was used, and it worked pretty well to permanently redirect older URLs to newer ones. However, after a recent WordPress update to 3.4.1 version, I noticed the older permalinks are no longer redirecting.

The problem is not with the plugin -- I have spent 2 days dabbling with every redirect plugin I could find. After a bit of Googling, I figured out the problem is with WordPress 3.4, and a bug has been already submitted.

Link: http://wordpress.org/support/topic/changing-permalinks-not-redirect-the-old-to-the-new#post-2913004

All the older URLs are throwing out 404 errors, which is frustrating. I'd really appreciate if there's a HTACCESS redirect code, or MOD_REWRITE code (the site is using nginx, if that helps) that could be posted here.

I have very little knowledge about redirection. Thanks a ton!

share|improve this question

2 Answers 2

You can try this but not 100% sure it will work since the post_id is not in the original permalink structure.

RedirectMatch 301 ^/([0-9]{4})/([^/]+)/([^/]+).html$ http://domain.com/$2/$3/

share|improve this answer
    
Chris, thanks a lot! The code almost works -- yes, there is no post_ID in the original permalink, and the URLs do not redirect properly. I tweaked the code a bit: RedirectMatch 301 ^/([0-9]{4})/([^/]+)/([^/]+).html$ domain.com/?p=$1 This redirects to another random post, although this is not what I need. Adding (\d+) to the HTML structure solves the problem, but our older permalink structure doesn't have post_ID as you have already mentioned. What do you think is the best solution? How can we inject post_ID in these URLs? –  Sid Jul 4 '12 at 13:56

First of all how are you possibly using mod_rewrite rules in an nginx powered site? That's a neat trick I'd like to learn :)

Anyway if you are using Apache try this:

RedirectMatch 301 ^/([0-9]{4})/([^/]+)/([^/]+).html$ example.com/?name=$3

The above uses the post's slug instead of the ID (which is missing in the old URLs). WP should redirect again to your SE friendly URLs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.