.htaccess files – Basics

A small note on .htaccess file.

What is .htaccess?

.htaccess is a configuration file for use on web servers running the Apache Web Server. When an .htaccess file is placed in a directory it is detected by the web server and gets exectued.These .htaccess files are used to alter the configuration of the Apache Web Server to enable/disable additional functionality and features that the Apache Web Server software has to offer.

A sample .htaccess file :

AuthName "security check"
AuthUserFile /path/to/password/file/.htpasswd
AuthType Basic
require valid-user
ErrorDocument 401 /error_pages/401.html

As per the above .htaccess file, it enables password protection on the directory; it offers redirection to a custom error page if a user fails to login correctly.

This is just a basic example.

.htaccess files are very powerful and they can be extremely fine tuned to meet your needs.