.htaccess
files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.
An .htaccess file controls how Apache interacts with your site. It is used to alter the requests and modify default behavior without needing to alter the core server configuration files.
Setting up .htaccess
is as simple as opening a notepad and saving it as .htaccess
. Generally, this file will placed on the root
directory of your website files, but you can use it under multiple different directories. This is especially useful if you're looking to password protect specific directories.
Sometimes even a single error in your
httpd.conf
or.htacces
s file will result in a temporary meltdown of the server, and users will see 500 - Internal Server Error page. So, make sure to always make a backup of yourhttpd.conf
and.htaccess
files before you make a change.
<Directory "/var/www">
AllowOverride All
</Directory>
.htaccess
files are normally enabled by default. This is controlled by AllowOverride
directive in the httpd.conf
file. This directive can only be placed inside of a <Directory>
section.
Beside All
there are numerous other values that limit configuration of only certain contexts. Some of them are:
.htaccess
.# Only allow .htaccess files to override Authorization and Indexes
AllowOverride AuthConfig Indexes