How to Change Permalink Structure and Setup Redirects in WordPress

Rohit Palit by | Updated:

Last month, I changed the month and year based permalink structure of TechTage to a simpler one based on just the post name. When I initially changed the structure from WordPress settings, I was quick to notice that old links were not working any more. With a quick .htaccess tweak, I was able to fix that and so far all my old URLs are 301 redirecting to the current ones. This was a lot easier to achieve than I had anticipated, and I’m going to show how you can do it too in this post.

NOTE: This tutorial is only for switching from a different permalink structure to the simple %postname% structure. In some cases like when you’re switching from a less to more informative URL structure, you don’t actually have to setup redirects manually tweaking your .htaccess. WordPress automatically handles the job for you. Test (load your old URLs) before you proceed!

Here are the steps:

1. Choose the ‘/%postname%/’ Structure from in WordPress ‘Permalink Settings’

The title explains it all. You just check the box next to ‘/%postname%/’ and click on ‘save changes’ at the bottom.

wordpress-permalink-settings

2. Use Yoast’s Redirects Generator

The most useful tool for the purpose, hands down.

  1. Click on the green ‘generate redirects’ button at the bottom of the post.
  2. Input your site’s URL.
  3. Specify if your blog is running in a subfolder (such as /blog).
  4. Select your old permalink structure.
  5. Generate the code responsible for the redirect.

The code looks something like this:

Yoast-URL-Redirects-Generator

3. Modify Your .htaccess

The last step involves adding the previously generated piece of code to the .htaccess file of the root directory of your WordPress installation. You can do this via a control panel (like cPanel) or FTP.

This shouldn’t be hard. All you’ll need to do is to open the old .htaccess file, and add the code to the top of it (yeah, of course you need to save the changes!).

Mission Accomplished!

That’s pretty much all. A nice and easy way to introduce the next level of simplicity to your site’s URL structure, and it involves only three steps!

Let me know how it goes for you, in case you try this. Also let us all know if you happen to know about an even easier process to achieve the same result.

  • This is just perfect! After hours of searching for a redirection option for my almost 2,000 posts when I switch permalink structure, I bumped into this and had everything all setup in less than 3 minutes. Thanks man, you just made my evening!

  • This is extremely straightforward. Collins actually recommended this post to me and it worked so well. Thanks a lot.

    For anyone who gets 404 errors because the old links have a .html extension, you can fix it by going to your WP Dashboard>Settings>Permalinks> and then edit the permalink to look like this /%postname%.html
    and then save it.

    It would resolve old .html URLs that are generating a 404 error.

  • >