- 1 Tips and Tricks for Detecting Insider Threats
- 2 Red Hat Enterprise Linux 7.5 Debuts with Improved Server Admin Features
- 3 Opportunity Lost: Enterprises Could Slash Cloud Costs by 36 Percent
- 4 Intel Sheds Wind River Embedded Division
- 5 Linux 4.16 Released with Improved Security, Virtualization Features
Using .htaccess Files with Apache Page 2
.htaccess
' isn't universally acceptable, though.
Sometimes it can quite difficult to persuade a system to let you create
or edit a file with such a name. For this reason, you can change the
name that Apache will use when looking for these per-directory
config files by using the AccessFileName
directive in your
server's httpd.conf
file. For instance,
AccessFileName ht.aclwill cause Apache to look for files named
ht.acl
instead of.htaccess
. They'll be treated the same way, though, and they're still called '.htaccess
files' for convenience.Locating and Merging
.htaccess
FilesWhen Apache determines that a requested resource actually represents a file on the disk, it starts a process called the 'directory walk.' This involves checking through its internal list of
<Directory>
containers to find those that apply, and possibly searching the directories on the filesystem for.htaccess
files.Each time the directory walk finds a new set of directives that apply to the request, they are merged with the settings already accumulated. The result is a collection of settings that apply to the final document, culled from all of its ancestor directories and the server's config files.
When searching for
.htaccess
files, Apache starts at the top of the filesystem. (On Windows, that usually means 'C:\
'; otherwise, the root directory '/
'.) It then walks down the directories to the one containing the final document, processing and merging any.htaccess
files it finds that the config files say should be processed. (See the section on overrides for more information on how the server determines whether an.htaccess
file should be processed or not.)This can be an intensive process. Consider a request for
<URI:http://your.host.com/foo/bar/gritch/x.html>
which resolves to the fileC:\Program Files\Apache Group\Apache\htdocs\foo\bar\gritch\x.htmlUnless instructed otherwise, Apache is going to look for each of the following
.htaccess
files, and process any it finds:
- C:\.htaccess
- C:\Program Files\.htaccess
- C:\Program Files\Apache Group\.htaccess
- C:\Program Files\Apache Group\Apache\.htaccess
- C:\Program Files\Apache Group\Apache\htdocs\.htaccess
- C:\Program Files\Apache Group\Apache\htdocs\foo\.htaccess
- C:\Program Files\Apache Group\Apache\htdocs\foo\bar\.htaccess
- C:\Program Files\Apache Group\Apache\htdocs\foo\bar\gritch\.htaccess
That's a lot of work just to return a single file! And the server will repeat this process each and every time the file is requested. See the overrides section for a way to reduce this overhead with the
AllowOverride None
directive.