Build Your Own Business Website header image

How to create 301 Redirects using an .htaccess file

Difficulty Level -

Filed Under Topics - , ,

Listed Under Lesson Subjects - ,

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

Part 1 – 404 Errors

This is the first part of a series discussing how to use 301 redirects in an .htaccess file in order to resolve 404 errors. In this first part we discuss what a 404 error is, how to tell if you have them and what to do about it.

Video Transcript

And actually, we’re going to spend a little bit of time talking about this because actually, it’s… you know, I could show a down and dirty piece of code but I’d rather you know, give you a full understanding of how this whole 301 redirect htaccess file works together. So I made a little presentation on it.

It’s great, thank you.

And so the purpose for a 301 redirect is to avoid a 404 error and a 404 error is a page not found error that you know, someone thinks a page exists and they type in a specific address and then the page doesn’t show up.

And so for example, if we go to my site… oops, I just turned on Photoshop instead of going to my site. If we go to my site and let’s say, Video tutorials, Intermediate tutorials… How to Build a Boat…well obviously, I don’t have a How to Build a Boat page here. But somebody typed that URL in and Photoshop came up. Anyway, somebody typed that URL in and we get this 404 error and this is my customized 404 error page that you know, identifies a potential mistake and suggest that they look in the Site Map or they search over here. But maybe, what we’d say is How to Build a Website or let’s see, How to Customize the Nav Menu, that’s also going to return a 404 error.

Oh I thought it would also give me some suggestions back but anyway, this is the 404 error page. Now, it’s not that a big a deal when you know, somebody types in the wrong address. However, Google checks your site for 404 errors because Google keeps track of all the pages that it has in its index and it follows those pages. And when it’s following those pages, it… I’m going to spit this out. When it’s following those pages and finds that URL that it thinks exists doesn’t exist, it registers an error. And you don’t want those errors to exist because… let’s see… where’s my… there it is. You don’t want those errors to exist because often times, those are legitimate links to that site. Whether it’s an external link or it’s an internal link from inside your site, you end up having this broken connection. And these broken connections are caused generally speaking, by changes to your site.

So for example, if you change or rearrange your categories or if you re-categorized posts or if you renamed pages, that will break the links between the old page and the you know, the newly renamed page or the newly re-categorized page and will return a 404 error.

So the way you know if you have 404 errors is to you know, establish a Google Webmaster Tools account and then look in Webmaster Tools to see. And so that’s what we’re going to do here.

This is my Webmaster Tools account and we’re going to go to our client site that has a couple of 404 errors that we’re going to work on here today. It’s the and if we open up the, on the dashboard, you can see it’s got a little list of crawl errors or Not Found errors. And if we come over to diagnostics and search… or go down to crawl errors, you can see that it lists the crawl errors that it has experienced or Not Found errors and here’s the error number, 404. And if you click on these links over here, you can see which pages are linking to this page. And so, clicking on that you can see there’s a whole bunch of internal links, 13 internal links that link back to that page that Google says does not exist.

Now, it can be the case that the page actually does exist and for whatever reason, for the split second Google was looking and couldn’t find it, so you can double check that first by clicking on the link there. But you can see, here we are. There is no page called Category Food Alert Recalls and so, it is in fact, returning a 404 error. And so, we’re going to have to work on that in order to make it go away.

So the way to solve 404 errors is to use a 301 permanent redirect and in most of your sites, probably everybody that’s here and probably 99% of the members of my site, you’re going to create a permanent redirect in the file called the htaccess file. Now this only works in Linux-based servers and you know, most web servers out there are Linux-based. But if you’re on a Windows server and using IIS instead of Apache then you won’t be doing this in the htaccess file. There’s another analogy for this. But I’m not going to worry about that here because I don’t think that really applies to anybody here.

0 Comments… add one
0 comments… add one