Build Your Own Business Website header image

How to create 301 Redirects using an .htaccess file – Part 2 – .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.

This is the second part of a series discussing how to use 301 redirects in an .htaccess file in order to resolve 404 errors. In this part we discuss what an .htaccess file is, what it does and how to create one.

Video Transcript

So what is an htaccess file? Well, an htaccess file is a ASCII file such as you would create through a text editor like Notepad, for example, or I think probably Text Mate or whatever that text editor is in the Mac. I forgotten now at the top of my head but it’s a very simple you know, we’ll create a plain text file.

And in fact, htaccess is the file extension. It’s not really the file name. So you know, in regular understanding of filenames, what you have is a filename and then a dot and then an extension. And so… or file extension.

And so, in this case, the htaccess actually has no file name. That dot is simply its file extension and otherwise, a file then is blank. So it’s not file.htaccess or some page.htacess… it’s just .htaccess which means it’s not possible or generally not possible to create that in Windows. As you’ll see in a moment, what you have to do is create a text file and then upload that to your server and then rename that so that it can be .htaccess.

So what is an htaccess file? Htaccess file or what they call in Apache, a distributed configuration file, provides a way to make server configuration changes on a per directory basis. Now, everything you can do in an htaccess file could be done if you were the systems administrator of your server. You could actually do all that stuff in server configuration files. But you know, most, perhaps, all of us, are not our server admins. We are working on some kind of a shared or virtual private shared hosting environment and in that case, we don’t have access to the server configuration files and the only way we can address this then is to have a directory by directory, htaccess file, to make these configuration changes.

And essentially what it is is a file that contains one or more configuration directives and it’s placed in a specific document directory and the directives that are in that file are applied to that directory and all of the rest of the subdirectories inside of that directory.

Okay so how do you create an htaccess file? Now in the first place, lots and lots of WordPress installations automatically create an htaccess file when you install WordPress. So you may already have an htaccess file and if you do have one… I forgot to have Filezilla up and running for this. If you do have one, for example, we go to my website. I have an htaccess file. You go to the root of your website and then if you scroll down to where you’ve actually got your files, you will see…if it’s… let’s make sure they’re alphabetical. Maybe it’s at the very bottom, okay, it’s in here someplace. Yeah, there it is, htaccess.

And so, you may already have an htaccess file so you want to check to make sure before you create one because you can only have one htaccess file in a directory. But in order to create one, you would just open up your plain text editor, like in this case, I’m going to use Notepad. And you would just have a plain text file and type, save as, and then go save it in a place you’re going to use to upload it. So in my case, I am uploading this in websites and client sites, foodwatchdog okay… and this is that root directory. And I’m just going to type in here htaccess.txt and you want to make sure that you keep the ANSI encoding. You don’t want to do Unicode or Unicode big endia or UTF-8. You want to keep the ANSI encoding for this and hit save. And then go ahead and close it and then in Filezilla, you will… let’s see, got to find that. You’re just going to upload it and then rename it in Filezilla.

So here it is, htaccess.txt so we’ll just go ahead and upload that to the website and then come over to it and rename it on the website to .htaccess. And now we have a .htaccess file that is essentially blank.

Now while I can’t create one like this in Windows, Windows will store it for me. And so, the next thing I’ll do then is just download this back to my site and then I’ve got my htaccess file here and it’ll be easy for me to address with my editor.
Oh, that’s right. We also have to give it appropriate permissions and let’s see, if we look at permissions for htaccess, that actually is the appropriate permission, 644. But if you don’t have it set at 644, you do need to… let’s see, set the file permissions and I just put the numeric value in here, 644. I think next week, we’re going to talk about what these permission settings mean and have a little primer on permission settings but for the time being, just type the numeric value in 644 and say okay to that and you’ll have that permission set correctly.

0 Comments… add one
0 comments… add one

Leave a Comment