1

Currently I don't have categories or anything else in my URLs, posts are just:

www.domain.com/%postname%/

I am updating my permalink structure to include the category though (actually a category and a sub-category), so it will be like:

www.domain.com/%category%/%postname%/

I know that when you are editing a post and you edit the slug, that WP will record that edit and automatically put a 301 redirect for you. However this does not work for changing the permalink structure like I am.

I have over 2,000 posts and have been looking for a plugin to somehow help with this to no avail. There is also no code that I can find (like matching the "%postname%" (which will be unique) and auto 301'ing based on that).

So right now my best strategy seems to be bulk extracting all my post URLs, separating them into the new categories by group, and then running some sort of text manipulation to create the required .htaccess rules (or to import them into the redirection plugin). This is a lot of work though and I am not certain I will even be able to work it out.

I also forgot to add that out of all those 2,000 posts that have no category in their URLs currently, they will all be going into one of 4-5 possible category/sub-category combinations! Some could be domain.com/cat1/cat2/title/ others domain.com/cat1/cat4/title, etc.

If I am missing an issue way to take care of this redirect issue please let me know. Otherwise it seems like a feature that WP would greatly benefit from.

  • 1
    Are you sure this doesn't work already? When you switch the permalink structure and try to access www.domain.com/foo/, WordPress is smart enough to look for posts with the slug foo and will redirect to www.domain.com/mycategory/foo automatically. See redirect_canonical() for details. – swissspidy Jan 18 '18 at 11:11
  • @swissspidy thank you for responding! I have not actually tested this thoroughly as many posts have similar URLs and I could already see WP getting confused with many redirects caused by the redirection plugin also. In short, I didn't see any way to achieve what I wanted properly and with certainty, so I decided to forget changed the permalink structure and just create categories virtually (breadcrumbs) etc instead. – Matt Jan 24 '18 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.