1

How to use the .htaccess file

The .htaccess file is a small and powerful text file that controls many aspects of how your webpages display. Things like redirects, enabling compression, rewriting urls, leveraging browser caching and more can be accomplished by adding some code to this little file.
However, even a small mistake while changing or updating this file can cause extreme results (like your webpages not showing up) so there is reason
to take great care when editing, but don’t be too scared, I will describe how to safely change it by ensuring you always have a backup copy of it that works.

What is a .htaccess file?

The name stands for “hypertext access”. The file provides a way to do things to your webserver that would normally be done in configuration files of your webserver. That access allows you the webmaster to do many things that you may not have known were possible. The .htaccess file is used by Apache and Litespeed and others. It is very likely that 90 percent of you reading this can use this file.

How do I find my .htaccess file?

Wherever you upload things to your webhost (like a file manager) is where you will find it. It is important to note that the .htaccess file is by default a “hidden” file. Most webhosts will provide an option to “see hidden files” when first opening the file manager. It is also worth noting that there can be no .htaccess file, or several. In theory every folder can contain one. Typically however the .htaccess file will be on the “root” level or the “www” folder. Basically wherever you put your files to be displayed on the web, that will be the most likely place to find the .htaccess.
If you can not find it, or you are unsure you have one you will need to contact your webhost and ask about it. If you are serious about your website, you should really know where this file is and how to use it. Many things you can do with this file will help you follow the Google webmaster guidelines better.

How do I edit my .htaccess file?

This file is just a text file, so you can edit it the same way you edit any other file on your webhost. However, before you do there is an important step to take…
Always make a copy of your current .htaccess file before altering it!
I really mean it. Make a copy first, call it something like “htaccess-works” or something, but really, you need to make a copy of it. Remember, altering this file wrong can screw up your website or even make your website not display at all. If you have a copy then you do not need to worry about it.

Best Practices for editing the .htaccess file

  • Always have a working functioning copy of your .htaccess file
  • Every time you make a change to this file you should save the file, then go to your webpage and refresh the browser to make sure your webpages are still displaying correctly. Doing this will save you many problems.
  • If you do screw something up, just copy and paste the contents of your backup copy into the .htaccess file and save it again and your website will work as it did before.

Post a Comment

  1. DreamHost is one of the best hosting company with plans for any hosting needs.

    ReplyDelete

 
Top