Restructuring your website doesn’t need to cause errors. In this post we’ll show you how to create what is known as a 301 redirect.
What happens when you delete a page?
The answer is that if you delete a page or a post or a category you will break any links to that web address.
As there is no web page to display, the web server sends a page that simply says “404 Page not found”. 404 errors can have a negative effect on your website’s search ranking and can be frustrating for site users.
Prevent errors in the first place.
Think twice before you delete content. If the blog post is old, consider rewriting it, keeping the permalink unchanged. If you significantly change the post content you can update the publish date, as we have done with this post.
How to safely delete content from your site
Don’t just delete content from your site → redirect the user to a new URL where the content now lives or where they can find related content.
A 301 redirect is a permanent redirect telling the browser and Google, when a site visitor tries to access this URL, send them to this URL instead.
During the restructuring process, make careful note of all pages, posts, categories and tags you are deleting. Search engines index archive pages so you need to include the URL for any deleted categories and tags in your list for redirection as well.
[clickToTweet tweet=”Don’t just delete #WordPress pages/posts → redirect to where content is now or related URL pic.twitter.com/Wud2KzKTIg” quote=”Don’t just delete #WordPress pages/posts → redirect to where content is now or to related content”]
How to create a 301 redirect in WordPress
Not only do you not need a redirection plugin to create a 301 redirect, but you shouldn’t use one. Most WordPress redirect plugins store 301 redirects in the WordPress database. Writing redirects to the WordPress database will make your site significantly slower. And page speed is important—-important for SEO and for user experience.
It is preferable to create 301 redirects in your website’s .htaccess file. The .htaccess file loads before the WordPress database, making the redirection faster.
Use The Yoast SEO Plugin to create a 301 redirect in the .htaccess file
To access your .htaccess file use the Yoast SEO plugin.
SEO → Tools → File editor
This tool allows you to quickly change important files for your SEO, like your robots.txt and your .htaccess file.
In the .htaccess file add a redirect for each page you want to redirect.
redirect 301 /old https://yoursite.com/new/
- replace /old.htm with your old URL. Do not include https:// or www in the old. Do include the full path from the top level of your site to the page
- replace https://yoursite.com/new/ with the full path. Match the site address URL exactly as found on your site’s Settings → General page — including http:// or https:// or www. Include a trailing slash (/) at the end of your URL
- when updating permalinks include your focus keyword
- put each redirect on its own line.
You may need to clear your site cache to see the 301 redirect in action.