Changing your WordPress permalink structure can have a powerful impact on your site’s SEO. When you change your permalink structure you run the risk of creating 404 errors when search engines and other sites have linked to your content. Server errors, especially 404, are very detrimental to your SEO and traffic values. Luckily, there are a number of steps you can take to change your permalinks without 404 errors.
1. Update your .htaccess
If you don’t want to hunt down a plugin to do the redirects for you, and if you have access to your files, you can make a small edit to your .htaccess file. This is relatively simple, and it only requires one line of code to make the change. First you will want to make a backup of your .htaccess file in case you make a mistake, and for the example below you will want to update your permalink structure to /%postname%/.
RedirectMatch 301 /([0-9]+)/([0-9]+)/(.*)$ http://www.yourdomain.com/$4
The code above will redirect your site if you followed the permalink structure of /%year%/%monthnum%/%postname%/ or /yyyy/mm/ and redirect it to /%postname%/. You will also want to replace yourdomain.com with your actual domain.
2. Find a permalink plugin
There are a number of redirect plugins which provide 301 redirects for your content. Most plugins, however, help you with maintenance rather than a mass migration of content addresses. Permalink plugins are available for your choosing, but not all of those will accomplish the goal of changing your permalinks without 404 errors.
Steps to Migrate Permalinks
Migrating permalinks are three easy steps once the advanced permalinks plugin is installed.
- Go to Settings > Permalinks. Copy the structure as seen in the Custom Structure field.
- Update the permalink structure to the one you wish to use moving forward. In my case, I selected Post Name or /%postname%/. Save changes.
- Click on the Migration link at the top of the screen, and post your copied structure in the Old permalink field and click Add. You’re done!
Monitor and Improve
I like to use the redirection plugin for management and maintenance of URLs after the migration is complete to catch those that may not be working. The plugin allows you to log redirects as well as 404 errors. It’s most important to log 404 errors. This will tell you if some redirects are not working or if you have a broken address from incoming links. You can log redirects, but it may be easiest for you to manage by watching the 404 errors. You will want to correct these as soon as possible.