What is htaccess?

Posted on by Jay Allen | Updated:
Reading Time: 2 minutes

Htaccess (HyperText Access) is a powerful file that can control many aspects of how your website functions. .htaccess works with several types of servers, but is most commonly found in use with the Apache web server.

Why .htaccess?

The .htaccess file appears in a directory listing as what is called a dot file (.htaccess). The dot (or period) before the file name indicates that it is a hidden file, something that should not be accessible by users connecting to the server. This file is hidden because of the important role it fulfills. A user could easily “hack” or deface a website by gaining unauthorized control over a .htaccess file.

Please note that this is an overview of the .htaccess file and what it can be used for. This article is not a guide for how to implement any of the common tasks below. If you are looking for specific information on how to accomplish any of the tasks listed here please see the references and tools links found towards the bottom of this page.

Common Tasks

Authentication
When used with a .htpasswd file .htaccess can be used to limit access to specific places in a website.

Rewriting URLs
.htaccess files can be used to rewrite long, complicated URLs into a more simple, shorter format. Quite often this is used to make websites easier for search engines to index.

Custom Error Messages
You can create custom web pages that you would like to use and have the .htaccess file tell the web server to use them instead of the default error pages.

Limiting Access
You can create rules in the .htaccess file which will only allow certain IP addresses or a range of IPs to connect to a site, or conversely, create rules to block specific IP addresses or a range of IPs. This is useful when launching a new website and you only want to allow a small, specific set of users to connect to the site (provided you have or can obtain their IP addresses).

DirectoryIndex
By default, apache looks for files called index.html, index.php, etc when trying to figure out what the “Directory Index” for that particular website is supposed to be. Using the Directory Index statement in the .htaccess file you can tell apache what file to use for the index.

For example:

DirectoryIndex newindex.php

This statement in an .htaccess file tells apache to load newindex.php as the default page instead of looking for index.php or a similar index file (Note: There is no space between the two words when using them in an .htaccess file).

Online Htaccess References & Tools

There are so many actions you can perform with the htaccess file that is next to impossible to memorize all of them (and more importantly how to implement all of them), so a good set of references and tools is extremely useful. A simple google search for htaccess will yield tens of millions of results, but here is a collection of links and resources that we use in the Liquid Web support department:

.htaccess Generator
Apache htaccess Info
htaccess-Guide

Remember, always backup your old .htaccess file before you start making changes!

===

Liquid Web’s support team is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985
International 517.322.0434
support@liquidweb.com

Avatar for Jay Allen

About the Author: Jay Allen

Latest Articles

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article