Redirect Wordpress Permalink in htaccess

I want to change the permalink structure of my site from /%postname%/ to /%category%/%post_id%/%postname%/ , and have the old backlinks redirect to the new structure (currently getting 404's). I have tried a couple of different redirection plugins (Redirection, 301 Simple Plugins) and I can't get them to work.

Can someone show me the rule to put in the htaccess file instead?

Thanks!

Answers


If you know the explicit category and post_id for a given postname, then you can create the redirects individually:

Redirect 301 /example-post-name-to-redirect/ /example-category/1234/example-post-name-to-redirect/ 

or using mod_rewrite (note, these rules must be before your wordpress rules:

RewriteRule ^example-post-name-to-redirect/$ /example-category/1234/example-post-name-to-redirect/ [L,R=301]

But the better solution is just using wordpress to do this for you, have you tried: UrbanGiraffe Redirection plugin, Scott Yang's Permalink Redirect WordPress Plugin, or Yoast's Permalink Redirect WordPress Plugin?


Need Your Help

How do I create different sessions for different windows in a desktop application with ActiveRecord?

nhibernate activerecord castle-activerecord castle

I'm building a desktop application with Castle ActiveRecord and want to be able to do the equivalent of 1 nHibernate session per window form. Any ideas on how can I do this with Active Record?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.