How to Redirect Old Posts URL After Changing Permalinks Structure?

For WordPress users, if you’ve set the old permalinks structure as /%postname%/, you might want to adjust the permalink slug to /%category%/%postname%/ for SEO benefits or other reasons.

Now, this type of permalink structure adjustment isn’t uncommon. However, you might notice that after changing the permalink structure, the old post URLs result in 404 errors—nothing exists at those URLs anymore.

For example, the old URL mywebsite.com/post-name simply can’t jump to the new URL mywebsite.com/category-name/post-name.

So, how do you solve this 404 error problem for the old post URLs?

If your website doesn’t have many posts, you can manually set up a 301 redirect for each post. It won’t take much time or effort.

But what if you’ve published hundreds or thousands of posts before adjusting the permalink structure? Manually creating 301 redirects for all of them isn’t realistic, is it?

I’ve been searching for the best solution, exploring third-party plugins, editing .htaccess, and adding PHP codes to functions. Unfortunately, there hasn’t been an ideal solution—until I stumbled upon a plugin that’s been installed on my website for quite some time: Redirection.

You can download it for free here: Redirection WordPress Plugin

Redirection allows you to set up URL redirections via 301, 302, or 307. It neatly solves your URL update needs. But here’s the exciting part: I discovered that this plugin can handle bulk redirections as well!

In my initial test, I set up a new redirection to redirect /%postname%/ to /%category/postname%/,and I read the warning message below, it became clear that I needed to add migrated permalinks to the Site page under the “Permalink Migration” section.

 

It dawned on me immediately that this was the solution I had been seeking. Yes, the “Redirection” plugin finally grasped the issue I was trying to address.

Next, I navigated to the “Site” tab and scrolled down to the “Permalinks Migration” section. I configured it as follows:

This will automatically redirect the old URL, mywebsite.com/post-name, to the current one, /category-name/post-name, which I adjusted in the Settings -> Permalinks structure.

This straightforward solution will automatically redirect all your old posts to the new ones, incorporating the category name in the slug.

 

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *