I recently came across this issue with a website a friend of mine runs and I thought it would be really simple to solve (e.g. just a fairly standard redirect rule in the .htaccess file)… not quite as it turns out!
The website in question had it’s permalink structure for posts set to www.website.com/year/month/day/postname. But as the posts were timeless or “evergreen” (meaning that they weren’t related to a specific date and should be current at all times) we just wanted the structure to be www.website.com/postname. Simply changing the structure in WordPress is the easy part. You just go to Settings > Permalink Settings and click on the Post name option and hit save. The problem is that if there are any backlinks to your posts (e.g. links on other websites to your content) then those won’t get updated and if clicked on will end up on a 404 page. That’s bad for business… and SEO!
It turns out that the awesome guys behind Yoast, the ubiquitous SEO plugin for WordPress (https://yoast.com/) have created a super useful little tool to create the redirect rule we need. It saves a lot of time trying to faff around and figure out the right syntax.
Just go here and put in your details and the tool will generate the rule: https://yoast.com/research/permalink-helper.php
That rule will then need to go into your .htaccess file which live in your main webspace folder. If you’ve never heard of the .htaccess file then fear not. Most hosting companies allow you to modify files in your webspace using a ‘File Manager’. If you’ve got one of those great… just find the .htaccess in your main website directory (the same place you’d find wp-config.php), then open it and add the rule at the bottom. Might be worth making a backup of that file before you make any changes by either copying and pasting the contents into a text file or downloading the file and keeping in a safe place. If the above sounds too scary just ask your hosting support guys to do it for you… they are usually happy to do that kind of thing!
And that’s it… as long as you’ve also changed the structure in Settings, the old links should be redirecting to their new versions. Boom!