Simple Code to Redirect 404 Errors in Your Blog – Improves SEO?

I’ve always kinda wondered about 404 errors. Whether they are important to keep up with, how they affect SEO on a blog and the best way to handle them. It’s one of those things that I always put off since they didn’t seem to be making much difference.

At least that’s what I thought, but I was wrong!!

So I’ve been doing some research and experimenting lately. And finally came up with a very simple solution to redirect 404 errors to any page of your wordpress blog.

I’m going to show you a little piece of code for a 301 redirect that is even simpler than installing a WP plugin, and works like a charm.

>>>> UPDATE – Go here – and read post before you decide to redirect 404 errors <<<<

After I found that post and talked to some intelligent people in the internet marketing and SEO field, I’ve returned my 404 error page’s. Though some people might disagree with that and want to redirect their 404 errors still. If you know what you’re doing with redirects, then it can help you, but if you don’t, then I suggest you don’t mess with it. I don’t ever want to publish false information or something that might not be true so I did even more extensive research after I wrote this post. I’ve never claimed I don’t make mistakes, but I sure as heck learn from them and correct the ones that I can.

This is why I started to care about 404 errors

I was checking out my Google Webmaster tools the other day, and I saw the amount of crawl errors on my blog. Let’s just say it was enough to make me freak out, just a little. I had several links that were leading to 404 errors. And the worst part was, many of them were from months ago.

Also, I am currently going back and SEO optimizing my blogs to the fullest and consolidating my categories to make life easier for my visitors. It’s something I’ve been meaning to do, but was worried about having a bunch of dead links or crawl errors.

So I knew I needed to get on top of this, and figure out a solution that not even a non-techie (me) could handle by their self.

*** Let me Clarify Something ****

If you insert the 301 redirect code below, then you won’t know if you have any dead links – links in your blog that either no longer exist, or just incorrectly misspelled. Because many people would like to know this information. And if you’re one of them, then I suggest you install a WP plugin for redirecting 404 errors.

Most of the plugins will let you know what links are leading to 404 errors and allow you to redirect them to wherever you want, and allow you to go back and fix any links not working properly.

The 301 redirect code, is more for anyone who doesn’t care about their 404 errors, and just want them to be redirected somewhere else on their blog, and not ever have to worry about them. Also, for anyone who wants to help other pages in their blog to rank better by redirecting any link juice going to the 404 error page, to the page of their choice.

WordPress plugins?

There are several WP plugins that handle 404 errors and can redirect them. But I just wasn’t satisfied with any of them. Plus I like to figure things out on my own and at least experiment. Some of the plugins were too complicated for what I wanted, and others were messing up my theme.

I love plugins, don’t get me wrong. But you don’t want to go and install as many as you can. Too many WordPress plugins can slow down your site. And some of them, might not play nicely with each other, or with your theme. So I started experimenting with the coding, and found exactly what I wanted.

How do 404 errors hurt your blog?

First off, if you don’t have too many 404 errors, then you’ll probably be fine. But still, it’s worth taking caring of them when you see them.

Let me explain why.

When someone clicks on a link that no longer exists or maybe spelled incorrectly, they’ll be lead to your 404 error page. Almost all WordPress themes have them, and usually it’s a plain page that says

404 error – this page no longer exists

Unless someone changed it to something different.

1 – this causes not the best experience to the visitor and you could lose them forever. Now some 404 error pages might have other suggestions for them or other links to your site, and etc…. but there’s still something better for SEO purposes.

Keep reading…

2 – Google and other search engine spiders will crawl and find these dead links. This creates the crawl errors that you’ll see in your Webmaster Tools. Now I’ve heard that your blog won’t get penalized too badly, or any at all for the 404 errors. But I think differently.

Instead of the spiders crawling links that lead to a 404 error page, they could be spending more time crawling your other content. Plus 404 e r r o r pages aren’t filled with content, that’s never a good thing. Makes sense to me at least.

You could block 404’s in the Robots.txt, but then they won’t know they exist and this could possibly create a different kind of error. This is what I’ve heard in forums. Never tried it before on my own so don’t know for sure. I’d rather redirect them.

3 – You’re losing link juice, opportunities to make more money and even loyal readers. On your site, all links pointing to other pages in your blog that no longer work -either because the link is misspelled, or the page no longer exists, are going to the 404 error page. Same thing goes for other blogs/sites that linked to yours, but leading to your 404 error page. That link juice is going to a page that you don’t care about and is being wasted.

You’re losing money and loyal readers because instead of leading them to a page that you want them to see, they are being lead to a blank 404 error page. Which doesn’t really help anyone out.

Finally, the 301 Redirect Code

First off, for those who don’t know already, a 301 redirect means it’s permanent. And yes, it passes link juice.

Now you need to go into your WordPress dashboard under appearance, then editor. You should see your blogs 404.php. If you don’t have one, then you’ll need to make one by going to your cpanel in your hosting and upload it to your blog’s files with a ftp.

There’s actually 2 different codes

Make sure you save a copy of the original 404.php page, just in case the codes below don’t work with your blog!!

#1 — This code below will redirect all of your 404 errors to your homepage. Just completely replace your 404.php with the code below.
————————————————————————————————————————
<?php

header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: “.get_bloginfo(‘url’));

exit();

?>
————————————————————————————————————————-

#2 — This code will redirect your 404 error to any page that you enter in the blank url spot. Maybe a money page that you want to get ranked higher or whatever you choose.
————————————————————————————————————————-
<?php
header(“Status: 301 Moved Permanently”);
header(“Location:http://url”);
?>
————————————————————————————————————————-

There you have it, you now have some options to redirect 404 errors to your homepage for a wordpress blog, or any other page that you desire even without using a plugin. It was actually really quite simple to do. And now you’re probably thinking, why did I wait so long?

Have any input on this matter? Then please don’t hesitate to share by leaving a comment. And if you found this post helpful, then do me a favor and share it with others by using one of the social buttons. I’d appreciate it.

Pin on PinterestDigg thisShare on StumbleUponShare on Google+Share on RedditShare on FacebookEmail this to someoneTweet about this on Twitter

Leave a reply