I’ve found myself in this situation a couple of times. The site has a date based permalink structure but the client want’s to remove them.
The correct way of doing this would be to add a 301 permanent redirect, and here’s how I do it:
- Install these two plugins; Redirection and List URLs.
- Go to
Tools > List URLs
and click download CSV. Then open up your favorite spreadsheet editor and remove everything but the posts with date based url’s. - Now you have a nice clean column A with the posts you need to redirect. So then you can head on over to
Settings > Permalinks
and change to pretty permalink or whatever you want, keep in mind that your old posts are now returning 404, but that’s about to change. - Repeat step 2 and copy that column to the first spreadsheet as column B so you should now have two columns with old and new urls, save your spreadsheet as clean csv.
- Head on over to
Tools > Redirection > Import/Export
and add your spreadsheet CSV and that’s it. Make sure everything is working by clicking one of the old URL’s.
Pretty easy, you should now have 301 permanent redirect from date based to pretty permalinks. I’ve seen other solutions like adding some redirection magic to your .htaccess but if you’re on WordPress Multi Site this get’s somewhat complicated. Also you have a nice interface for all your redirections which IMHO gives you better control.
Hey,
The easiest and most clever post ever!
One question: must I copy to speadsheet the whole url like https://www.domainname.com/2019/post-name or just the second part of it /2019/post-name
Please, I would be grateful for any advice!
Eddie
Thanks :)
I usually copy the whole URL. I’m not sure if you could leave the domain name out, but it probably doesn’t matter.