GCS Amplitude
GCS Amplitude

Apache Module mod_mime

Effective filter "DEFLATE" AddOutputFilter DEFLATE shtml

Effective filter "INCLUDES", replacing "DEFLATE" AddOutputFilter INCLUDES shtml

Effective filter "INCLUDES;DEFLATE", replacing "DEFLATE" AddOutputFilter INCLUDES;DEFLATE shtml

Effective filter "BUFFER", replacing "INCLUDES;DEFLATE" AddOutputFilter BUFFER shtml

No effective filter, replacing "BUFFER" RemoveOutputFilter shtml

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

for more information about mod_negotiationcontent negotiation.

are all used to map file extensions onto the metadata for that file. Respectively they set the character set, content-encoding, content-language, and AddTypemedia-type (content-type) of documents. The directive

may define the mod_mimehandler and filters that originate and process content. The directives

to consider these file extensions to be included when testing Multiviews matches.mod_negotiation

server provides directives that are used to associate all the files in a given container (coree.g.,

. The core directives override any filename extension mappings defined in SetOutputFilter

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.

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

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

Care should be taken when a file with multiple extensions gets associated with both a media-type and a handler. This will usually result in the request being handled by the module associated with the handler. For example, if the .imap

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*

processed as a CGI script, but not the file bar.cgi.html

, then instead of using AddHandler cgi-script .cgi

SetHandler cgi-script

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 pkzip file encoding, then the file Resume.doc.zip

header with the resource, in order to tell the client browser about the encoding method.

) to determine which document to give to the client, when there are alternative documents in more than one character set, language, encoding or mime type. All filename extensions associations created with mod_negotiation

) participate in this select process. Filename extensions that are only associated using the MimeMagicFile

directives may be included or excluded from matching by using the AddOutputFilter

To convey this further information, Apache optionally sends a Content-Language

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

AddLanguage ja .ja AddCharset EUC-JP .euc AddCharset ISO-2022-JP .jis AddCharset SHIFT_JIS .sjis

will be treated as being a Japanese document whose charset is ISO-2022-JP

directive is useful for both to inform the client about the character encoding of the document so that the document can be interpreted and displayed appropriately, and for content negotiation, where the server returns one from several documents based on the client's charset preference.

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.

AddEncoding x-gzip .gz AddEncoding x-compress .Z

Old clients expect x-gzip

, however the standard dictates that they're equivalent to gzip

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

) 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

for these two specific encodings. More recent encodings, such as deflate

Once that has been put into your apache2.conf file, any file containing the .cgi

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 AddLanguage

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:

directive, any definition made will replace any previous definition made by the AddOutputFilter

AddType image/jpeg jpeg jpg jpe

A simmilar effect to

can be achieved by qualifying a LanguagePrioritymedia-type with qs

AddType application/rss+xml;qs=0.8 .xml

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.

) should be assigned a Content-Language of AddLanguagelanguage-tag. This allows entire directory trees to be marked as containing Dutch content, for instance, without having to rename each file. Note that unlike using extensions to specify languages, DefaultLanguage

components as part of the filenameModMimeUsePathInfo On|Off

This directive is recommended when you have a virtual filesystem.

will now treat the incoming request as mod_mime/index.php/foo.shtml

filter will not be added. This will work analogously for virtual paths, such as those defined by

MultiviewsMatch Any|NegotiatedOnly|Filters|Handlers [Handlers|Filters]

option provides that every extension following the base name must correlate to a recognized

extension for content negotiation, mod_mimee.g. Charset, Content-Type, Language, or Encoding. This is the strictest implementation with the fewest unexpected side effects, and is the default behavior.

, 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

file would win in this example. Users of .asis

doesn't recognize the extension. This can cause unpredictable results, such as serving .old or .bak files the webmaster never expected to be served.mod_mime

For example, the following configuration will allow handlers and filters to participate in Multviews, but will exclude unknown files:

as an unencoded plaintext file.

directives, so it is possible they may undo the effects of the latter if both occur within the same directory configuration.AddEncoding

directory to being treated as normal files, rather than as candidates for parsing (see the

This will remove any special handling of .cgi

directory and any beneath it, causing responses containing those files to omit the HTTP Content-Type header field.

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 apache2.conf

file by providing the majority of media-type definitions, and may be overridden by

directives as needed. You should not edit the AddTypemime.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

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.

Modules | Directives | FAQ | Glossary | Sitemap

Apache HTTP Server Version 2.4

Apache Module mod_mime

Available Languages: en | fr | ja

Files with Multiple Extensions

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

Content encoding

A file of a particular media-type can additionally be encoded a particular way to simplify transmission over the Internet. While this usually will refer to compression, such as gzip, it can also refer to encryption, such a pgp or to an encoding such as UUencoding, which is designed for transmitting

Character sets and languages

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

AddCharset Directive

The AddCharset directive maps the given filename extensions to the specified content charset (the Internet registered name for a given character encoding). charset is the media type's charset parameter for resources with filenames containing extension. This mapping is added to any already in force,

AddEncoding Directive

The AddEncoding directive maps the given filename extensions to the specified HTTP content-encoding. encoding is the HTTP content coding to append to the value of the Content-Encoding header field for documents named with the extension. This mapping is added to any already in force, overriding any m

AddHandler Directive

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:

AddInputFilter Directive

AddInputFilter maps the filename extension extension to the filters which will process client requests and POST input when they are received by the server. This is in addition to any filters defined elsewhere, including the SetInputFilter directive. This mapping is merged over any already in force,

AddLanguage Directive

The AddLanguage directive maps the given filename extension to the specified content language. Files with the filename extension are assigned an HTTP Content-Language value of language-tag corresponding to the language identifiers defined by RFC 3066. This directive overrides any mappings that alrea

AddOutputFilter Directive

The AddOutputFilter directive maps the filename extension extension to the filters which will process responses from the server before they are sent to the client. This is in addition to any filters defined elsewhere, including SetOutputFilter and AddOutputFilterByType directive. This mapping is mer

AddType Directive

The AddType directive maps the given filename extensions onto the specified content type. media-type is the media type to use for filenames containing extension. This mapping is added to any already in force, overriding any mappings that already exist for the same extension.

DefaultLanguage Directive

The DefaultLanguage directive tells Apache that all resources in the directive's scope (e.g., all resources covered by the current container) that don't have an explicit language extension (such as .fr or .de as configured by AddLanguage) should be assigned a Content-Language of language

ModMimeUsePathInfo Directive

The ModMimeUsePathInfo directive is used to combine the filename with the path_info URL component to apply mod_mime's directives to the request. The default value is Off - therefore, the path_info component is ignored.

MultiviewsMatch Directive

MultiviewsMatch permits three different behaviors for mod_negotiation's Multiviews feature. Multiviews allows a request for a file, e.g. index.html, to match any negotiated extensions following the base request, e.g. index.html.en, index.html.fr, or index.html.gz.

RemoveCharset Directive

The RemoveCharset directive removes any character set associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files.

RemoveEncoding Directive

The RemoveEncoding directive removes any encoding associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files. An example of its use might be:

RemoveHandler Directive

The RemoveHandler directive removes any handler associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files. An example of its use might be:

RemoveInputFilter Directive

The RemoveInputFilter directive removes any input filter associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files.

RemoveLanguage Directive

The RemoveLanguage directive removes any language associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files.

RemoveOutputFilter Directive

The RemoveOutputFilter directive removes any output filter associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files.

RemoveType Directive

The RemoveType directive removes any media type associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files. An example of its use might be:

TypesConfig Directive

The TypesConfig directive sets the location of the media types configuration file. File-path is relative to the ServerRoot. This file sets the default list of mappings from filename extensions to content types. Most administrators use the mime.types file provided by their OS, which associates common