5.12. Overrides

We can do more with overrides than speed Apache up. This mechanism allows the webmaster to exert finer control over what is done in .htaccess files. The key directive is AllowOverride.

5.12.1. AllowOverride

AllowOverride override1 override2 ...
Directory

This directive tells Apache which directives in an .htaccess file can override earlier directives. The list of AllowOverride overrides is as follows:

AuthConfig

Allows individual settings of AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, and require

FileInfo

Allows AddType, AddEncoding, and AddLanguage

Indexes

Allows FancyIndexing, AddIcon, AddDescription (see Chapter 7)

Limit

Can limit access based on hostname or IP number

Options

Allows the use of the Options directive (see Chapter 4)

All

All of the above

None

None of the above

You might ask: if none switches multiple searches off, which of the above options switches it on? The answer is any of them, or the complete absence of AllowOverride. In other words, it is on by default.

To illustrate how this works, look at .../site.override, which is .../site.htaccess with the authentication directives on the salespeople's directory back in again. We have also, to make a visible difference, commented out:

require group cleaners

and uncommented:

#require valid-user

The Config file is as follows:

User webuser Group webgroup ServerName www.butterthlies.com AccessFilename .myaccess ServerAdmin sales@butterthlies.com ...

Get Apache: The Definitive Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.