Short explanation of .htaccess

[ambient page updated 11 Oct 05] ... [ home ] ... [ garrett@umn.edu ]

# this is a comment
#
# It seems that comments should be only at the _beginning_ of lines,
# or else the server gets confused
#

######################################################################
###
### NOTE: As of August 2003, the new configuration of our Apache server may
### have disallowed some of this stuff... I haven't checked yet.
###
######################################################################

#
# In the directory that you want to influence by the directives you
# should put a file called ".htaccess" (no quotes) which is world
# readable (not executable!) containing lines giving the directives below.
#

#
# Default processing order is "deny"'s first, then "allow"'s
# The following would process "allow"s first, then "deny"s
#
# order allow, deny
#
# Note that we comment this out, since it's probably better to
# do "deny"'s first, as the default has it.

#
# To disallow everyone:
#
deny from all

#
# Can allow from specific host, for example after denying from all
#
allow from 9128.101.154.149

#
# Can allow from domain(s) of various granularity
#
allow from 128.101
allow from 128.101.154 

#
# Can also use human-readable version rather than IP addresses:
#
allow from math.umn.edu

#
# Can use the Redirect directive, as in (note the syntax)
#

Redirect /~garrett/index.html http://www.math.umn.edu/~garrett/tmp/index.html

#
# The following means that any .data will be executed
# (if its permissions are set right, anyway)
#
AddHandler cgi-script data

#
# Can also define "custom" handlers, for specified suffixes:
# Here "sfx" is the filename suffix to be treated specially,
# and the script through which it will be run is specified
# from the server root directory
# 

AddHandler my-new-handler sfx
Action my-new-handler /~garrett/somedirectory/foo.cgi

#
# To redirect errors toward your own error document, add a line
#

ErrorDocument 404 http://www.math.umn.edu/~me/myerror.html

#
# Of course, this can also route bad requests through a handler, etc,
# to customize response depending on lost or mis-named file
#
######################################################################


Unless explicitly noted otherwise, everything here, work by Paul Garrett, is licensed under a Creative Commons Attribution 3.0 Unported License. ... [ garrett@umn.edu ]

The University of Minnesota explicitly requires that I state that "The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota."