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?
Last week a client who wants to restructure some content on her site asked me “What happens when a page is deleted?”
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.
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.
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.
[cross posted on LearnWP.ca]
One thought on “How to create a 301 redirect when you delete a page”
Thanks Ruth. Yoast’s plugin solves a dilemma for those of us who don’t have enough knowledge to create 301 Redirects and need to alter our website info. And your post clearly outlines how to use the plugin without stress.
Comments are closed.