What are dead links?
WordPress evolved into much more than a blogging platform. It has become a full-fledged CMS, with many tools to enhance both article writing and management. However, WordPress (or any other CMS) can’t avoid dead links, usually known as 404 errors.
What are 404 errors?
404 errors are thrown by the server to notify a browser that the page/resource you are looking for was not found at the URL you typed. This usually happens when people mistype page URLs. However, these errors also occur if a page is deleted or its URL modified.
Redirecting WordPress to the homepage
If you want to redirect the browser every time a page can’t be found while avoiding SEO impact, you can open your 404.php file in your theme’s folder. If it doesn’t exist, then create a blank .php file. Paste the following code in there:
// If you want to redirect the browser every time a page can’t be found while avoiding SEO impact, you can open your 404.php file
// in your theme’s folder. If it doesn’t exist, then create a blank .php file. Paste the following code in there:
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . get_bloginfo('url'));
Now when a user hits a 404 page will be redirected to the homepage.
Customized 404 pages.
Many WordPress themes provide customized a custom 404 page so that the site shows a much more helpful page to you visitors. Having some guiding info is much better than the ugly and unhelpful “Page not found” page or a simple 301 redirect. Some of these pages are very cool and provide a lot of useful tips to the user on how to find the missing page or post.
Sounds great, right? However, there is almost always a problem when things sound too good to be true, isn’t there? The problem is that if you use a redirect to go from an error page to a normal page, the redirecting page will return a “200 OK” or a 302 Redirect code, rather than proper 404 errors.
Since there is no redirect code (it’s a pure 200 OK), search engines get a whole bunch of indexed URL’s all looking like duplicates of your home page. Search engines “hate” duplicate content, causing a duplicate-content penalty. This ends up lowering your site’s ranking on result pages, no matter how good your site is.
The Redirection plug-in
That’s why this should be used in very specific cases. In most other cases (i.e blogs, portfolios etc), you should track your 404 pages and redirect them appropriately. You can use tools such as the Redirection plugin, which tracks 404 errors (and its referrers) and allows you to redirect dead links to the right page, and generally tidy up any loose ends your site may have.
This tool is particularly useful if you are migrating pages from an old website, or are changing the directory or permalink structure of your WordPress installation, as it will allow users and search engines to find content when it can’t be found at the original URL, without 404 errors or duplicate-content penalties.