Summary
The module mod_mime associates the request filename's extensions (for example, .html) with the file's behavior (handlers and filters) and content (mime-type, language, character set and encoding). This module is used to determine various bits of "meta information" with files by their filename extensions. This information relates to the content of the document to its mime-type, language, character set and encoding. This information is sent to the browser, and participates in content negotiation. The user's preferences are respected when choosing one of several possible files to serve. In addition, a handler can be set for a document that determines how the document will be processed within the server. See Module mod_negotiation for more information regarding content negotiation.
The directives AddCharset, AddClient, AddEncoding, AddHandler, AddLanguage, and AddType are all used to map file extensions onto the meta-information for that file. Respectively they set the character set, content-encoding, handler, content-language, browser, and MIME-type (content-type) of documents.
In addition, mod_mime may define the document handler that controls which module or script will serve the document. With the introduction of filters, mod_mime can also define the filters that the the content should be processed through (for example, the Includes output filter for server side scripting) and what filters the client request and POST content should be processed through (the input filters).
The directives AddHandler, AddOutputFilter, and AddInputFilter control the modules or scripts that serve the document. The MultiviewsMatch directive allows mod_negotiation to consider these file extensions when testing Multiviews matches.
The directive TypesConfig is used to specify a file that also maps extensions onto MIME types. Most administrators use the provided mime.types file that associates common filename extensions with IANA registered content types. The current list is maintained at http://www.isi.edu/in-notes/iana/assignments/media-types/media-types .
The core directives ForceType and SetHandler are used to associate all the files in a given container (<location>, <directory>, or <files>) with a particular MIME-type or handler. These settings override any filename extension mappings defined in mod_mime.
Note that changing the type or encoding of a file does not change the value of the Last-Modified header. Therefore, previously cached copies may still be used by a client or proxy, with the previous headers. If you change the meta-information (language, content type, character set or encoding) you may need to update affected files (updating their last modified date) to ensure that all visitors are receiving the corrected content headers.
Files with Multiple Extensions
Files can have more than one extension, and the order of the extensions is normally irrelevant. For example, if the file welcome.html.fr maps onto content type text/html and then language French, the file welcome.fr.html will map onto exactly the same information. The only exception to this is if an extension is given which HTTP Server (powered by Apache) does not handle. In this case it will forget about any information it obtained from extensions to the left of the unknown extension. For example, if the extensions fr and html are mapped to the appropriate language and type, but extension xxx is not assigned to anything, then the file welcome.fr.xxx.html will be associated with content-type text/html but no language.
If more than one extension is given that maps onto the same type of meta-information, then the one to the right will be used. For example, if ".gif" maps to the MIME-type image/gif and ".html" maps to the MIME-type text/html, then the file welcome.gif.html will be associated with the MIME-type "text/html".
When a file with multiple extensions gets associated with both a MIME-type and a handler be careful. This will usually result in the module associating a request with the handler. For example, if the .imap extension is mapped to the handler "imap-file" (from mod_imap) and the .html extension is mapped to the MIME-type "text/html", then the file world.imap.html will be associated with both the "imap-file" handler and "text/html" MIME-type. When it is processed, the imap-file handler will be used, and it will be treated as a mod_imap imagemap file.
Directives
Module: mod_mime | |
Syntax: AddCharset charset extension [extension...] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: AddCharset ISO-2022-JP .jis |
The AddCharset directive maps the given filename extensions to the specified content charset. Charset is the MIME charset parameter of filenames containing extension. This mapping is added to any already in force, overriding any mappings that already exist for the same extension.
This directive is useful for informing the client about the character encoding of the document so it can be interpreted and displayed appropriately. It also used for content negotiation. Content Negotiation is where the server returns one from several documents based on the client's charset preference.
- Parameter One: charset
- The charset parameter value is any valid MIME character set.
- Parameter Two: extension
- The extension parameter value is any character string that is a valid file extension.
See Module mod_negotiation for more information.
Module: mod_mime | |
Syntax: AddClient user-agent extension | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: none | |
Origin: iSeries™ | |
Example: AddClient Mozilla/2.0 .moz | |
Example: AddClient IBM* .ibm |
The AddClient directive binds files with a particular extension to the type and version of the browser (user-agent) that is sending the request. This is often referred to as Automatic Browser Detection. All HTTP requests contain a User-Agent header that identifies the client browser. Based on this User-Agent header, the server can respond with a specific version of the resource (with the extension specified) that is especially appropriate for the client browser.
- Parameter One: user-agent
- The user-agent parameter value matched in the User-Agent header of the incoming request. This is case-sensitive. The asterisk may be used as a wildcard character.
- Parameter Two: extension
- The extension parameter value is the file extension that should be associated with the browser. Wildcards cannot be used.
Module: mod_mime | |
Syntax: AddEncoding MIME-enc extension [extension...] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: AddEncoding x-gzip gz |
The AddEncoding directive maps the given filename extensions to the specified encoding type. MIME-enc is the MIME encoding that is used for documents containing the extension. This mapping is added to any already in force, overriding any mappings that already exist for the same extension.
Old clients expect x-gzip and x-compress, however the standard dictates that they're equivalent to gzip and compress respectively. HTTP Server (powered by Apache) does content encoding comparisons by ignoring any leading x-. When responding with an encoding the HTTP Server will use whatever form (for example., x-QIBM or QIBM) the client requested. If the client didn't specifically request a particular form, the server will use the form given by the AddEncoding directive. In conclusion 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-.
- Parameter One: MIME-enc
- The MIME-enc parameter value should be set to a content-encoding supported by HTTP/1.1. Currently, these values are 'gzip', 'compress' and 'deflate'.
- Parameter Two: extension
- The extension parameter value is any string that is a valid file extension.
Module: mod_mime | |
Syntax: AddHandler handler-name extension [extension...] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: AddHandler cgi-script cgi |
The AddHandler directive maps the filename extensions to handler 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:
AddHandler cgi-script cgi
Once this has been put into your configuration file, any file containing the ".cgi" extension will be treated as a CGI program.
- Parameter One: handler-name
- The handler-name parameter value is the name of the handler (program) that will process the request.
- Parameter Two: extension
- The extension parameter value is any character string that is a valid file extension.
AddHandler can also be used to configure the use of Server Side Includes. This is done with the following directive combination:
AddType text/html .shtml AddHandler server-parsed .shtml
See Handler for HTTP Server (powered by Apache) for more information.
Module: mod_mime | |
Syntax: AddInputFilter filter extension [extension ...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: AddInputFilter gzip .zip |
The AddInputFilter directive maps the filename extensions extension to the filters that 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, overriding any mappings that already exist for the same extension.
If SuffixCaseSense is on (default is off), then the extension argument is case-insensitive. The extension can be specified with or without a leading dot.
- Parameter One: filter
- The filter parameter value is the process that is applied to data that is sent or received by the server.
- Parameter Two: extension
- The extension parameter value is any character string that is a valid file extension.
- Example
<Directory/www/data/> AddInputFilter gzip Zip </Directory>
See the Apache Software Foundation filter documentation for more information.
Module: mod_mime | |
Syntax: AddLanguage MIME-lang extension [extension...] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: AddLanguage fr .fr |
The AddLanguage directive maps the given filename extensions to the specified content language. MIME-lang is the MIME language of filenames containing extension. This mapping is added to any already in force, overriding any mappings that already exist for the same extension.
Even though the content language is reported to the client, the browser is unlikely to use this information. The AddLanguage directive is more useful for content negotiation, where the server returns one from several documents based on the client's language preference.
If multiple language assignments are made for the same extension, the last one encountered is the one that is used.
- Parameter One: MIME-lang
- The MIME-lang parameter value is any valid MIME-language designation.
- Parameter Two: value
- The extension parameter value is any character string that is a valid file extension.
See Module mod_negotiation for more information.
Module: mod_mime | |
Syntax: AddOutputFilter filter extension [extension ...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: AddOutputFilter INCLUDES shtml |
The AddOutputFilter directive maps the filename extensions extension to the filters that process responses from the server (before they are sent to the client). This is in addition to any filters defined elsewhere, including the SetOutputFilter directive. This mapping is merged over any already in force, overriding any mappings that already exist for the same extension.
For example, the following configuration will process all .shtml files for server-side includes.
AddOutputFilter INCLUDES shtml
If SuffixCaseSense is on (default is off), then the extension argument is case-insensitive. The extension can be specified with or without a leading dot.
- Parameter One: filter
- The filter parameter value is the process that is applied to data that is sent or received by the server.
- Parameter Two: extension
- The extension parameter value is any character string that is a valid file extension.
See the Apache Software Foundation filter documentation for more information.
Module: mod_mime | |
Syntax: AddType MIME-type extension [extension...] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: AddType image/gif GIF |
The AddType directive maps the given filename extensions onto the specified content type. MIME-type is the MIME 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. This directive can be used to add mappings not listed in the MIME types file. It is recommended that new MIME types be added using the AddType directive rather than changing the TypesConfig file.
- Parameter One: MIME-type
- The MIME-type parameter value is any valid MIME-type.
- Parameter Two: extension
- The extension parameter value is any character string that is a valid file extension.
Module: mod_mime | |
Syntax: DefaultLanguage MIME-lang | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: DefaultLanguage en-US |
The DefaultLanguage directive tells HTTP Server that all files in the directive's scope (for example, all files covered by the current <Directory> container) that don't have an explicit language extension configured by AddLanguage should be considered to be in the specified MIME-lang language. This allows entire directories to be marked as containing Dutch content, for instance, without having to rename each file. Note that unlike using extensions to specify languages, DefaultLanguage can only specify a single language.
If no DefaultLanguage directive is in force, and a file does not have any language extensions configured by AddLanguage, then that file will be considered to have no language attribute.
- Parameter: MIME-lang
- The MIME-langparameter value is any valid MIME-language designation.
See Module mod_negotiation for more information.
Module: mod_mime | |
Syntax: ModMimeUsePathInfo on | off | |
Default: ModMimeUsePathInfo off | |
Context: directory | |
Override: none | |
Origin: Apache | |
Example: ModMimeUsePathInfo on |
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, meaning the path_info component is ignored. This directive is recommended when you have a virtual filesystem.
For example, if ModMimeUsePathInfo is set to on, then a request for /bar/file.shtml where /bar is a Location, mod_mime will treat the incoming request as /bar/file.shtml and directives like AddOutputFilter INCLUDES .shtml will add the INCLUDES filter to the request. If ModMimeUsePathInfo is not set, the INCLUDES filter will not be added.
- Parameter: on | off
- The on parameter value specifies that filenames will be combines with path_info URL components.
- The off parameter value specifies that the path_info component is ignored.
- Example
ModMimeUsePathInfo onIf you have a request for /myfile/more.shtml where myfile is an existing file containing SSI, and AcceptPathInfo is set on in order to accept the actual file "myfile" as the requested file, and ModMimeUsePathInfo is on, mod_mime will treat the incoming request as SSI and directives like AddOutputFilter INCLUDES .shtml will add the INCLUDES filter to the request. If ModMimeUsePathInfo is not set, the INCLUDES filter will not be added. When ModMimeUsePathInfo is set, the trailing path name can be used to determine the content type of the existing file.
Module: mod_mime | |
Syntax: MultiviewsMatch NegotiatedOnly | Handlers | Filters | Any | |
Default: MultiviewsMatch NegotiatedOnly | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: MultiviewsMatch Handlers | |
Example: MultiviewsMatch Handlers Filters |
The MultiviewsMatch directive permits three different behaviors for mod_negotiation's Multiviews feature. Multiviews allows a request for a file (index.html for example) to match any negotiated extensions following the base request (for example, index.html.en, index.html.fr, or index.html.gz).
- Parameter: NegotiatedOnly | Handlers | Filters | Any
- The NegotiatedOnly parameter value specifies that every extension following the base name must correlate to a recognized mod_mime extension for content negotiation (for example, Charset, Content-Type, Language, or Encoding). This is the strictest implementation with the fewest unexpected side effects, and is the default behavior.
- The Handlers and Filters parameter value set the MultiviewsMatch directive to either Handlers, Filters, or both option keywords. If all other factors are equal, the smallest file will be served (for example, in deciding between index.html.cgi of 500 characters and index.html.pl of 1000 bytes, the .cgi file would be served). Users of .asis files might prefer to use the Handler option, if .asis files are associated with the asis-handler.
- The Any parameter value specifies that any extensions to match, even if mod_mime doesn't recognize the extension. This was the behavior in Apache 1.3, and can cause unpredictable results, such as serving .old or .bak files the webmaster never expected to be served.
Module: mod_mime | |
Syntax: RemoveCharset extension [extension...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: RemoveCharset .ext |
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 configuration files.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
Module: mod_mime | |
Syntax: RemoveClient extension [extension...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: iSeries | |
Example: RemoveClient .moz |
The RemoveClient directive removes any client (browser) 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.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
- Example
/work/.htaccess: RemoveClient .moz
If SuffixCaseSense is on (default is off), then the extension argument is case-insensitive. The extension can be specified with or without a leading dot. This removes any special handling of .moz files in the /work/ directory (and any subdirectories), thereby disabling automatic browser detection for files in this directory. The extension argument is case-insensitive, and can be specified with or without a leading dot.
Module: mod_mime | |
Syntax: RemoveEncoding extension [ extension...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: RemoveEncoding .gz |
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.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
- Example
/work/.htaccess: AddEncoding x-gzip .gz AddType text/plain .asc <Files *.gz.asc> RemoveEncoding .gz </Files>The example will cause work.gz to be marked as encoded with the gzip method, but cause work.gz.asc to be marked as an unencoded plaintext file.
Module: mod_mime | |
Syntax: RemoveHandler extension [extension...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Usage Considerations: RemoveHandler .html | |
Example: example |
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.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
- Example
/QIBM/.htaccess: AddHandler server-parsed .html /QIBM/bar/.htaccess: RemoveHandler .htmlThe example has the effect of returning .html files in the /QIBM/bar directory to being treated as normal files, rather than as candidates for parsing.
Module: mod_mime | |
Syntax: RemoveInputFilter extension [extension ...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: RemoveInputFilter .ext |
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 configuration files.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
Module: mod_mime | |
Syntax: RemoveLanguage extension [extension ...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: RemoveLanguage Fr |
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 configuration files.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
Module: mod_mime | |
Syntax: RemoveOutputFilter extension [extension ...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: RemoveOutputFilter .ext |
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 configuration files.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
Module: mod_mime | |
Syntax: RemoveType extension [ extension...] | |
Default: none | |
Context: directory, .htaccess | |
Override: none | |
Origin: Apache | |
Example: RemoveType .cgi |
The RemoveType directive removes any MIME 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.
- Parameter: extension
- The extension parameter value is any character string that is a valid file extension.
- Example
/work/.htaccess: RemoveType .cgiThe example removes any special handling of .cgi files in the /work/ directory (and any beneath it), causing the files to be treated as the default type.
Module: mod_mime | |
Syntax: SuffixCaseSense on | off | |
Default: SuffixCaseSense off | |
Context: server config | |
Override: none | |
Origin: iSeries | |
Example: SuffixCaseSense on |
The SuffixCaseSense directive is used to specify whether the server should distinguish between uppercase and lowercase characters when it has to compare file extensions to the extension patterns on the following directives:
By default, the iSeries will not be sensitive to the case of the extensions.
- Parameter: on | off
- The on parameter value specifies the server will be sensitive to the case of file extensions.
- The off parameter value specifies the server will not be sensitive to the case of file extensions.
Module: mod_mime | |
Syntax: TypesConfig filename | |
Default: TypesConfig /QIBM/UserData/HTTPA/conf/mime.types | |
Context: server config | |
Override: none | |
Origin: Apache | |
Example: TypesConfig /conf/mime2.types |
The TypesConfig directive sets the location of the MIME types configuration file. Filename is relative to the ServerRoot. This file sets the default list of mappings from filename extensions to content types; changing this file is not recommended. Use the AddType directive instead. The file contains lines in the format of the arguments to an AddType command:
MIME-type extension [extension ...]
Blank lines, and lines beginning with a hash character (#) are ignored.
- Parameter: filename
- The filename parameter value is a filename where the MIME-type file can be located. This filename must be relative to the ServerRoot. This restricts the file to the IFS file system.