O'Reilly logo

Apache: The Definitive Guide, Second Edition by Peter Laurie, Ben Laurie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.11. Using .htaccess Files

We experimented with putting configuration directives in a file called ... /htdocs/.htaccess rather than in httpd.conf. It worked, but how do you decide whether to do things this way rather than the other?

The point of the .htaccess mechanism is that you can change configuration directives without having to restart the server. This is especially valuable on a site where a lot of people are maintaining their own home pages but are not authorized to bring the server down or, indeed, to modify its Config files. The drawback to the .htaccess method is that the files are parsed for each access to the server, rather than just once at startup, so there is a substantial performance penalty.

The httpd.conf (from ... /site.htaccess) file contains the following:

User webuser Group webgroup ServerName www.butterthlies.com AccessFilename .myaccess ServerAdmin sales@butterthlies.com DocumentRoot /usr/www/site.htaccess/htdocs/customers ErrorLog /usr/www/site.htaccess/logs/customers/error_log TransferLog /usr/www/site.htaccess/logs/customers/access_log ScriptAlias /cgi-bin /usr/www/cgi-bin <VirtualHost sales.butterthlies.com> ServerAdmin sales_mgr@butterthlies.com DocumentRoot /usr/www/site.htaccess/htdocs/salesmen ServerName sales.butterthlies.com ErrorLog /usr/www/site.htaccess/logs/salesmen/error_log TransferLog /usr/www/site.htaccess/logs/salesmen/access_log ScriptAlias /cgi-bin /usr/www/cgi-bin #<Directory /usr/www/site.htaccess/htdocs/salesmen> #AuthType Basic ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required