Starting from the Top
When you request any file from a web server, it returns a 'response code' along in the 'headers' of your request. These 'headers' are hidden from your browser by accessible if you do need to look at it.
Here is what the headers look like for this very blog post:
| HTTP/1.1 200 OK Content-Type: text/html Content-Length: 13418 Connection: keep-alive Date: Sun, 15 Feb 2016 23:37:22 GMT Last-Modified: Mon, 15 Feb 2016 01:02:32 GMT ETag: "dec3f6aecf1af792e608e22401c1b032" Server: AmazonS3 Vary: Accept-Encoding
A '200' response code means "we're all good, here's the file you wanted". See the example above.
A '404' response code means "this file doesn't live here" and then you can then show the user your usual 404 error page.
And for the geeks playing at home, a '418' response code is a little Easter Egg built into the specifications that simply says "I'm a teapot"!
404 Error Pages
Remember that you can display anything that you like on the 404 page.
It's always best to help the user find what they were after on a 404 page rather than them simply closing your website.
This could include:
- a search box
- auto suggest some similar pages based on what they tried to access
- a list of your most popular products/pages
'Soft' 404 Errors
You may have seen these 'Soft 404s' reporting in your Google Search Console.
This happens when you show your user your 404 error page but you are actually returns a '200' server response code to Google.
You definitely want to get these fixed up as it's sending very confusing signals to Google!
Are 404s bad?
The Google Webmaster Blog sums it up well:
404s are a perfectly normal part of the web; the Internet is always changing, new content is born, old content dies, and when it dies it (ideally) returns a 404 HTTP response code.
So 404 errors are not necessarily bad. They are actually the correct way to Google (or any user) that the page is gone (if it's meant to be gone and you don't want it back).
It is actually worse to:
- 301 redirect everything to your homepage.
- serve a 200 response on an old broken page (see the 'Soft' 404 error above).
When to 301 Redirect?
1. Always fix the problem at the source first!
A lot of 404's are created because a link to a page is broken has been typed incorrectly.
Find what page (or multiple) the problem occurred from (Google Search Console tells you this) and get it fixed there.
If the broken URL has been live for a long time, or has important external backlinks pointing at it, it's best to 301 redirect it also. If you only just made the error and then fixed it, it's fine to not 301 that.
2. There are a lot of backlinks going to an old page.
You see this case with a lot of old promotions (especially with subdomains such as https://letseattogether.cocacola.com). You set it up, people link to it, then you pull it down when it's finished.
This is a good one to 301 redirect back to your homepage to get the link juice from, unless you make a new, more appropriate page for it such as a wrap up or case study.
3. There is a lot of traffic going to that page.
Check Google Analytics to see if it's just a once accident where a visitor is hitting a broken page, or if an external website is linking to a broken page. If the latter, you should 301 redirect if you can't get the source fixed up.
4. It is an obvious error.
5. You made a great PDF resource that has external backlinks pointing at it.
And the PDF file is no longer needed.
When NOT to 301 Redirect?