I’m occasionally asked to redirect every 404 error on a site to the home page. There are a couple of reasons why you might not want to do this (see below) but there are also valid cases where it could be the right move for your site. If you’ve decided it’s the right thing to do, here’s how to accomplish it easily in WordPress:
Edit or create 404.php in your theme directory. Replace all of the content inside with the following lines:
And that’s all there is to it!
Why shouldn’t you do that?
There are a couple of reasons that redirecting all 404 errors could be problematic.
First, search engines are said not to pass all of a page’s link equity to the redirected page unless the content is very similar. So redirecting pages that used to rank well to the home page won’t work as a sneaky way to boost your home page.
Probably more importantly, though, is the fact that it will be difficult to monitor which links are 404ing since they’ll all just end up on the home page. The usefulness of Google Webmaster Tools and other methods of monitoring 404 requests is not just in preventing future 404s. The real power is that it helps you identify what your users are looking for and where they’re failing to find it. Fixing all 404s in an automated way makes that more difficult.
I’m very pleased to announce that I’ve released my first WordPress plugin. It’s called Simple 301 Redirects and it does just what it says on the tin. It provides an interface for redirecting URL requests. It’s handy for when you’ve migrated a site to WordPress and are unable to maintain the URL structure. With Simple 301 Redirects you can redirect your old urls like “/about.html” to new, clean URLs like “http://www.yoursite.com/pages/about/” or whatever you like. Redirecting your old links to new destinations is important for preserving inbound links and pagerank after migrating a site. And this plugin does it in the easiest possible way I could think of.
You can read a little bit more about the plugin at its official home on this site or go straight to the WordPress plugin directory to download it. I hope you find it helpful!
Quick tip: Search engines are designed to work for people, not the other way around. They’re designed to pick results that are likely to be what the searcher is looking for, and for a blog the post title is an important part of that. If you want people to find your blog post in a search engine and click through, do the following:
- Think about what you would type into Google if you were looking for whatever information you’re about to post. Make it specific.
- Put that in the title. You can add some more detail to make the title more “punchy,” but make sure your search phrase is in there.
- There is no step 3.
If a searcher sees exactly what she typed in the title of a search result she’s going to click. The trick is that your content has to support the title you picked. Otherwise, even if you trick the search engine, your site visitor will take one look and hit the back button.