This module is used to assign content metadata to the content
selected for an HTTP response by mapping patterns in the
URI or filenames to the metadata values. For example, the filename
extensions of content files often define the content's Internet
media type, language, character set, and content-encoding. This
information is sent in HTTP messages containing that content and
used in content negotiation when selecting alternatives, such that
the user's preferences are respected when choosing one of several
possible contents to serve. See
The directives
In addition,
While
Note that changing the metadata for a file does not
change the value of the Last-Modified
header.
Thus, previously cached copies may still be used by a client or
proxy, with the previous headers. If you change the
metadata (language, content type, character set or
encoding) you may need to 'touch' affected files (updating
their last modified date) to ensure that all visitors are
receive the corrected content headers.
Files can have more than one extension; the order of the
extensions is normally irrelevant. For example, if the
file welcome.html.fr
maps onto content type
text/html
and language French then the file
welcome.fr.html
will map onto exactly the same
information. If more than one extension is given that maps onto
the same type of metadata, then the one to the right will
be used, except for languages and content encodings. For example,
if .gif
maps to the image/gif
and .html
maps to the
media-type text/html
, then the file
welcome.gif.html
will be associated with the
media-type text/html
.
Languages and content encodings are treated accumulative, because one can assign
more than one language or encoding to a particular resource. For example,
the file welcome.html.en.de
will be delivered with
Content-Language: en, de
and Content-Type:
text/html
.
Care should be taken when a file with multiple extensions
gets associated with both a .imap
extension is mapped to the handler imap-file
(from
.html
extension is
mapped to the media-type text/html
, then the file
world.imap.html
will be associated with both the
imap-file
handler and text/html
media-type.
When it is processed, the imap-file
handler will be used,
and so it will be treated as a
If you would prefer only the last dot-separated part of the
filename to be mapped to a particular piece of meta-data, then do
not use the Add*
directives. For example, if you wish
to have the file foo.html.cgi
processed as a CGI
script, but not the file bar.cgi.html
, then instead
of using AddHandler cgi-script .cgi
, use
A file of a particular gzip
, it can also refer to encryption, such a
pgp
or to an encoding such as UUencoding, which is
designed for transmitting a binary file in an ASCII (text)
format.
The HTTP/1.1 RFC, section 14.11 puts it this way:
The Content-Encoding entity-header field is used as a modifier to the media-type. When present, its value indicates what additional content codings have been applied to the entity-body, and thus what decoding mechanisms must be applied in order to obtain the media-type referenced by the Content-Type header field. Content-Encoding is primarily used to allow a document to be compressed without losing the identity of its underlying media type.
By using more than one file extension (see section above about multiple file extensions), you can indicate that a file is of a particular type, and also has a particular encoding.
For example, you may have a file which is a Microsoft Word
document, which is pkzipped to reduce its size. If the
.doc
extension is associated with the Microsoft
Word file type, and the .zip
extension is
associated with the pkzip file encoding, then the file
Resume.doc.zip
would be known to be a pkzip'ed Word
document.
Apache sends a Content-encoding
header with the
resource, in order to tell the client browser about the
encoding method.
In addition to file type and the file encoding, another important piece of information is what language a particular document is in, and in what character set the file should be displayed. For example, the document might be written in the Vietnamese alphabet, or in Cyrillic, and should be displayed as such. This information, also, is transmitted in HTTP headers.
The character set, language, encoding and mime type are all
used in the process of content negotiation (See
To convey this further information, Apache optionally sends
a Content-Language
header, to specify the language
that the document is in, and can append additional information
onto the Content-Type
header to indicate the
particular character set that should be used to correctly
render the information.
The language specification is the two-letter abbreviation
for the language. The charset
is the name of the
particular character set which should be used.
The
Then the document xxxx.ja.jis
will be treated
as being a Japanese document whose charset is ISO-2022-JP
(as will the document xxxx.jis.ja
). The
The extension argument is case-insensitive and can be specified with or without a leading dot. Filenames may have multiple extensions and the extension argument will be compared against each of them.
The
This will cause filenames containing the .gz
extension
to be marked as encoded using the x-gzip
encoding, and
filenames containing the .Z
extension to be marked as
encoded with x-compress
.
Old clients expect x-gzip
and x-compress
,
however the standard dictates that they're equivalent to
gzip
and compress
respectively. Apache does
content encoding comparisons by ignoring any leading x-
.
When responding with an encoding Apache will use whatever form
(i.e., x-foo
or foo
) the
client requested. If the client didn't specifically request a
particular form Apache will use the form given by the
AddEncoding
directive. To make this long story
short, you should always use x-gzip
and
x-compress
for these two specific encodings. More
recent encodings, such as deflate
, should be
specified without the x-
.
The extension argument is case-insensitive and can be specified with or without a leading dot. Filenames may have multiple extensions and the extension argument will be compared against each of them.
Files having the name extension will be served by the
specified handler-name. This
mapping is added to any already in force, overriding any mappings that
already exist for the same extension. For example, to
activate CGI scripts with the file extension .cgi
, you
might use:
Once that has been put into your httpd.conf file, any file containing
the .cgi
extension will be treated as a CGI program.
The extension argument is case-insensitive and can be specified with or without a leading dot. Filenames may have multiple extensions and the extension argument will be compared against each of them.
If more than one filter is specified, they must be separated by semicolons in the order in which they should process the content. The filter is case-insensitive.
The extension argument is case-insensitive and can be specified with or without a leading dot. Filenames may have multiple extensions and the extension argument will be compared against each of them.
The
Then the document xxxx.en.Z
will be treated as
being a compressed English document (as will the document
xxxx.Z.en
). Although the content language is
reported to the client, the browser is unlikely to use this
information. The
If multiple language assignments are made for the same extension, the last one encountered is the one that is used. That is, for the case of:
documents with the extension .en
would be treated as
being en-us
.
The extension argument is case-insensitive and can be specified with or without a leading dot. Filenames may have multiple extensions and the extension argument will be compared against each of them.
The
For example, the following configuration will process all
.shtml
files for server-side includes and will then
compress the output using
If more than one filter is specified, they must be separated by semicolons in the order in which they should process the content. The filter argument is case-insensitive.
The extension argument is case-insensitive and can be specified with or without a leading dot. Filenames may have multiple extensions and the extension argument will be compared against each of them.
Note that when defining a set of filters using the
The
Or, to specify multiple file extensions in one directive:
The extension argument is case-insensitive and can be specified with or without a leading dot. Filenames may have multiple extensions and the extension argument will be compared against each of them.
A simmilar effect to qs
:
This is useful in situations, e.g. when a client
requesting Accept: */*
can not actually processes
the content returned by the server.
This directive primarily configures the content types generated for static files served out of the filesystem. For resources other than static files, where the generator of the response typically specifies a Content-Type, this directive has no effect.
If no handler is explicitly set for a request, the specified content type will also be used as the handler name.
When explicit directives such as
This is a historical behavior that may be used by some third-party modules (such as mod_php) for taking responsibility for the matching request.
Configurations that rely on such "synthetic" types should be avoided.
Additionally, configurations that restrict access to
index.html
, to match any negotiated
extensions following the base request, e.g.
index.html.en
, index.html.fr
, or
index.html.gz
.
The NegotiatedOnly
option provides that every extension
following the base name must correlate to a recognized
To include extensions associated with Handlers and/or Filters,
set the Handlers
, Filters
, or both option keywords.
If all other factors are equal, the smallest file will be served,
e.g. in deciding between index.html.cgi
of 500
bytes and index.html.pl
of 1000 bytes, the .cgi
file would win in this example. Users of .asis
files
might prefer to use the Handler option, if .asis
files are
associated with the asis-handler
.
You may finally allow Any
extensions to match, even if
For example, the following configuration will allow handlers and filters to participate in Multviews, but will exclude unknown files:
The .fr
or .de
as configured
by
If no
path_info
components as part of the filenameThe path_info
URL component to
apply Off
- therefore, the path_info
component is ignored.
This directive is recommended when you have a virtual filesystem.
If you have a request for /index.php/foo.shtml
/index.php/foo.shtml
and directives
like AddOutputFilter INCLUDES .shtml
will add the
INCLUDES
filter to the request. If INCLUDES
filter will not be added. This will work
analogously for virtual paths, such as those defined by
The .htaccess
files in subdirectories to
undo any associations inherited from parent directories or the
server config files.
The extension argument is case-insensitive and can be specified with or without a leading dot.
The .htaccess
files in subdirectories to undo
any associations inherited from parent directories or the
server config files. An example of its use might be:
This will cause foo.gz
to be marked as being
encoded with the gzip method, but foo.gz.asc
as an
unencoded plaintext file.
The extension argument is case-insensitive and can be specified with or without a leading dot.
The .htaccess
files in subdirectories to undo any
associations inherited from parent directories or the server
config files. An example of its use might be:
This has the effect of returning .html
files in
the /foo/bar
directory to being treated as normal
files, rather than as candidates for parsing (see the
The extension argument is case-insensitive and can be specified with or without a leading dot.
The .htaccess
files in subdirectories to
undo any associations inherited from parent directories or the
server config files.
The extension argument is case-insensitive and can be specified with or without a leading dot.
The .htaccess
files in subdirectories to undo
any associations inherited from parent directories or the
server config files.
The extension argument is case-insensitive and can be specified with or without a leading dot.
The .htaccess
files in subdirectories to
undo any associations inherited from parent directories or the
server config files.
The extension argument is case-insensitive and can be specified with or without a leading dot.
The .htaccess
files in
subdirectories to undo any associations inherited from parent
directories or the server config files. An example of its use
might be:
This will remove any special handling of .cgi
files in the /foo/
directory and any beneath it,
causing responses containing those files to omit the HTTP
Content-Type header field.
The extension argument is case-insensitive and can be specified with or without a leading dot.
mime.types
fileThe mime.types
file
provided by their OS, which associates common filename
extensions with the official list of IANA registered media types
maintained at http://www.iana.org/assignments/media-types/index.html
as well as a large number of unofficial types. This
simplifies the httpd.conf
file by providing the
majority of media-type definitions, and may be overridden by
mime.types
file,
because it may be replaced when you upgrade your server.
The file contains lines in the format of the arguments to
an
The case of the extension does not matter. Blank lines, and lines
beginning with a hash character (#
) are ignored.
Empty lines are there for completeness (of the mime.types file).
Apache httpd can still determine these types with
mime.types
file unless (1) they are already
registered with IANA, and (2) they use widely accepted,
non-conflicting filename extensions across platforms.
category/x-subtype
requests will be automatically
rejected, as will any new two-letter extensions as they will
likely conflict later with the already crowded language and
character set namespace.