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?
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?