Submitter: Ronnie Gauthier
The .htaccess file is a configuration file for Apache that controls access to a directory tree on the website. Some points to consider:
- Apache can be configured to ignore .htaccess files
- Apache can be configured to limit what a .htaccess file can specify
- .htaccess files apply to the directory they are in and every subdirectory (unless overridden by another .htaccess file)
Complete discussion of the options available to .htaccess files is beyond the scope of this document. Here we will focus only on some of the more common uses. For an in-depth look at all the options, please see Apache.org*.
- Redirect - sending the browser elsewhere
MULTIPLE allowed
Format is: Redirect <old> <new>
Example: Redirect fish.html fish/index.html
Example: Redirect birds.html http://birds.org/
- ErrorDocument - what to say when an error occurs
MULTIPLE allowed
Format is: ErrorDocument <error code> <output>
Example: ErrorDocument 404 /error/404.html
Example: errorDocument 500 "PANIC: does not compute
- DirectoryIndex - what page is displayed by default
ONE allowed
Format is: DirectoryIndex <index name> <index name>
Example: DirectoryIndex index.htm index.html
Example: DirectoryIndex index.php index.shtml index.html
- FancyIndex - generate "pretty" directory listings
ONE allowed
Format is: FancyIndex <on> <off>
Example: FancyIndex on
- ReadmeName - important information location
ONE allowed
Format is: ReadmeName <file name>
Example: ReadmeName readme
Notes: if a file named readme and a file named readme.html exist, the readme.html will come before readme in the directory listing
- HeaderName - directory listing header contents
ONE allowed
Format is: HeaderName <file name>
Example: HeaderName header
Notes: can contain text/HTML. May even contain and IMG link
- AddDescription - define a desciption for directory listing
MULTIPLE allowed
Format is: AddDescription "<desc. string>" <filename/extension/path>
Example: AddDescription "ISO image for creating CD-ROMS" .iso
- IndexIgnore - files to not display in directory listings
ONE allowed
Format is: IndexIgnore <pattern1> <pattern2>
Example: IndexIgnore *.jpg tmp.html
- Options - control what can and can't be done in this dir
??? allowed
Format: Options <+/-><option>
Example: Options +ExecCGI -Includes +Indexes
Notes: A '+' is used to ALLOW the directive, while '-' will DENY the directive. Also, if the '+/-' is left out, a '+' is ASSUMED