What Is an HTACCESS File?

This plain text file is an Apache configuration file that stands for 'hypertext access'

What to Know

  • An HTACCESS file is used by an Apache server to make configuration changes on a per-directory basis.
  • You can view the file's contents with a text editor, such as Notepad++.
  • Specialized converters can convert the file so it works with ​ASP.NET or Ngnix. 

This article explains what an HTACCESS file is, how and why they're used, and how to open or convert one.

What Is an HTACCESS File?

A file with the HTACCESS file extension is an Apache configuration file that stands for 'hypertext access.' These are text files used to invoke an exception to the global settings that apply to the various directories of an Apache website.

Placing the file in one directory will override the global settings that previously flowed down to that directory and its subdirectories. For example, HTACCESS files can be created for redirecting a URL, preventing directory listing, banning specific IP addresses, preventing hotlinking, and more.

Another common use for this file is for pointing to an HTPASSWD file that stores credentials preventing visitors from accessing that particular directory of files.

HTACCESS file in Windows 10 that opens with Notepad

Unlike other types of files, these don't contain a file name, so they look like this: .htaccess.

How to Open an HTACCESS File

Since these files apply to web servers that are running the Apache Web Server software, they don't take effect unless they're used within that context.

However, even a simple text editor is able to open or edit the file, like Windows Notepad or one from our Best Free Text Editors list. Another popular, though not free, HTACCESS editor is Adobe Dreamweaver.

How to Convert the File

You can convert the file to a ​Ngnix web server file using this online HTACCESS to nginx converter. You have to paste its contents into the text box to convert the code to one recognizable by Ngnix.

Similar to the nginx converter, the file can be converted to Web.Config using codebreak's online .htaccess to Web.Config converter. This one is useful if you want the file to work with an ASP.NET web application.

Sample File

Below is a sample .HTACCESS file. This particular file might be useful for a website that's currently under development and not yet ready for the public.

AuthType basicAuthName "Ooops! Temporarily Under Construction..."AuthUserFile /.htpasswdAuthGroupFile /dev/nullRequire valid-user # Password prompt for everyone elseOrder Deny,AllowDeny from allAllow from # The developer's IP addressAllow from w3.orgAllow from googlebot.com # Allows Google to crawl your pagesSatisfy Any # No password required if host/IP is allowed

Every line has a particular purpose. The htpasswd entry, for example, indicates that this directory is hidden from public view unless a password is used. However, if the IP address shown above is used to access the page, then the password isn't required.

Need More Help?

You should be able to tell from the sample above that these files are pretty flexible, so it's true that they're not the easiest to work with.

You can read more about how to use an HTACCESS file for blocking IP addresses, preventing viewers from opening the file, blocking traffic to the directory, requiring SSL, disabling website downloaders/rippers, and more at JavaScript Kit, ApacheWordPress, and DigitalOcean.

If you still can't open the file, you're probably misreading the file extension, confusing another format for this one—it's actually really easy to do that. HTA, for example, might look similar, but that extension is reserved for HTML application files, which usually open in Microsoft HTML Application Host. Another example is the HTC file extension.

Was this page helpful?