If you have blogged as long as I have, over 13 years as of the date of this post. You often run into old posts that are just no longer valid for you site or valid for your readers. It could be because the content is no longer valid. It could be a post on how to do something and the directions are no longer accurate because times change. You may automatically think that you can just delete the post and be done with it. However, this is not the correct solution.
Yes, you can delete the post so that it no longer shows up in your feed or searches. However, it will still show up in searches used by Google, Bing, and Yahoo. Once they are indexed by the search engines they are there and will come up in searches. This means that if someone does a search and clicks a link to an old post of yours and that post is deleted they will come to a 404 Error page. This isn’t a good thing to happen because Google hates 404 error pages.
How to: 301 Redirect How to post using .htaccess
There is a fairly easy process to fix this error though. There are several ways of doing this, however, this is the one way I found to be the easiest and quickest. You can still delete the post from your site. However, you need to add a small bit of code into your .htaccess file for each post you want to delete.
In order to do this process you will need access to your .htaccess file on your server (where your blog is hosted), a small line of code to place in the .htaccess file, and then you can delete the post or you can leave the post there and it will still redirect the post if someone goes to it.
Editing your .htaccess file
Although this is a very easy thing to do, you do have to be very careful when working with this file because if you make a mistake it can break your site. You can fix the problem if this occurs but it is always better to be very careful and only change what you need to and always make a backup copy of the file before editing it.
In order to redirect a post or page from your WordPress blog, you will need to have the exact URL of the post and include it in a small line of code. This code should be placed at the beginning of your .htaccess file. Nothing should be before any redirect codes.
Redirect 301 /old-page-name https://www.shawnann.com/new-page-name
That may look a little confusing but it is really easy. Here is an example of how I would want to redirect this post to different pages of Shawn Ann.
Redirect to the main site:
Redirect 301 /how-to-301-redirect-how-to-post-using-htaccess https://shawnann.com
Redirect to Mom Tech Category page:
Redirect 301 /how-to-301-redirect-how-to-post-using-htaccess https://www.shawnann.com/category/mom-tech/
Delete Irrelevant Post
This is an optional step, you do not need to delete the post, but if you know that you will never need to refer back to the post then you should just delete it. The only time you may want to not delete the post is if is something you might be able to update and/or fix later or create a new post from the information within that post. That way you don’t necessarily have to completely rewrite a post.