How to Open, Edit, & Convert HTACCESS Files

HTACCESS file in Windows 10 that opens with Notepad
HTACCESS File.

Screenshot 

A file with the HTACCESS file extension is an Apache Access 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 an HTACCESS 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 an HTACCESS file is for pointing to an HTPASSWD file that stores credentials preventing visitors from accessing that particular directory of files.

Note: Unlike other types of files, HTACCESS files don't contain a file name; they look like ".htaccess." That's right — no file name at all, just the extension.

How to Open an HTACCESS File

Since HTACCESS 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 an HTACCESS 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 an HTACCESS File

Apache web server files with the HTACCESS file extension can be converted to ​Ngnix web server files using this online HTACCESS to nginx converter. You have to paste the contents of the HTACCESSS file into the text box to convert the code to one recognizable by Ngnix.

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

Sample HTACCESS File

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

AuthType basic
AuthName "Ooops! Temporarily Under Construction..."
AuthUserFile /.htpasswd
AuthGroupFile /dev/null
Require valid-user # Password prompt for everyone else
Order Deny,Allow
Deny from all
Allow from 192.168.10.10 # The developer's IP address
Allow from w3.org
Allow from googlebot.com # Allows Google to crawl your pages
Satisfy Any # No password required if host/IP is allowed

Every line of this HTACCESS file 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.

Advanced Reading on HTACCESS Files

You should be able to tell from the sample above that HTACCESS files can do a lot of different things. It's true that they're not the simplest files to work with.

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