- Overview
- Installation & Uninstallation
- Local and remote management using IIS 7
- Context and processing order
- Apache compatibility
- Modules
- core functions
- mod_antibot
- mod_asis
- mod_auth_basic
- mod_auth_digest
- mod_authn_anon
- mod_authn_dbd
- mod_authn_default
- mod_authn_file
- mod_authz_default
- mod_authz_groupfile
- mod_authz_host
- mod_authz_user
- mod_cache
- mod_dbd
- mod_deflate
- mod_developer
- mod_dir
- mod_disk_cache
- mod_env
- mod_evasive
- mod_expires
- mod_filter
- mod_gzip
- mod_headers
- mod_hotlink
- mod_linkfreeze
- mod_log_config
- mod_logio
- mod_mem_cache
- mod_mime
- mod_proxy
- mod_replace
- mod_rewrite
- mod_seo
- mod_setenvif
- mod_so
- mod_speling
- mod_usertrack
- mod_xsendfile
 
- Articles
- Release history
- Troubleshooting
- License agreement
mod_mime
Overview
mod_mime module is used to associate meta information with files by their extensions. Meta information relates the filename of the document to it's mime-type, language, character set and encoding. This information is sent to the browser and participates in content negotiation so the user's preferences are respected when choosing one of several possible files to serve.
Note! Changing the meta information does not imply the change of Last-Modified header value and previously cached copy may still be used by a client or proxy with the previous headers. So, to ensure that all users get the fresh version of the resource it's advisable to visit it and subsequently renew its last modified date.
Files with multiple extensions
   Files can have more than one extension and usually the order of the extensions is insignificant.
For example, the file index.html.fr maps to content type
   
    text/html
   
   and language French
and  the file index.fr.html also maps to exactly the same information.
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, except for languages and content encodings.
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
   
   .
  
   Languages and content encodings are treated in the aggregate,
because more than one language or encoding may be assigned o a particular resource.
For example, the file index.html.en.de will be delivered with
   
    Content-Language: en, de
   
   and
   
    Content-Type: text/html
   
   .
  
Content encoding
   In addition to specifying the mime-type for the file it's also possible
to encode it to simplify its transmission over the Internet.
Generally, encoding implies compression (e.g.
   
    gzip
   
   ),
but it can also be encryption (e.g.
   
    pgp
   
   ) or
encoding such as
   
    UUencoding
   
   ,
which is designed for transmitting a binary file in an ASCII (text) format.
  
By using more than one file extension you can indicate that a file is of a particular type, and also has a particular encoding.
   For example, you have 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 recognized as a pkzip'ed Word document.
  
Character sets and languages
Along with file type and encoding there's one more worthy piece of information that is the language of the document and the character set the file should be displayed in. For example, the document might be written in the Chinese or Cyrillic and should be displayed correctly in any case. 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 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.
   The language of the document is specified in
   
    Content-Language
   
   header,
   
    Content-Type
   
   header is used to indicate the charset
to be used to correctly display the content.
  
Example
Content-Language: en, fr
Content-Type: text/plain; charset=ISO-8859-1Directives
| Name | Context | Description | 
|---|---|---|
| AddCharset | S V D .h | Maps the given filename extensions to the specified content charset | 
| AddEncoding | S V D .h | Maps the given filename extensions to the specified encoding type | 
| AddHandler | S V D .h | Maps the filename extensions to the specified handler | 
| AddInputFilter | S V D .h | Maps filename extensions to the filters that will process client requests | 
| AddLanguage | S V D .h | Maps the given filename extension to the specified content language | 
| AddOutputFilter | S V D .h | Maps filename extensions to the filters that will process responses from the server | 
| AddType | S V D .h | Maps the given filename extensions to the specified content type | 
| DefaultLanguage | S V D .h | Sets all files in the given scope to the specified language | 
| ModMimeUsePathInfo | S V D .h | Tells mod_mime to treat path_info components as part of the filename | 
| RemoveCharset | S V D .h | Removes any character set associations for a set of file extensions | 
| RemoveEncoding | S V D .h | Removes any content encoding associations for a set of file extensions | 
| RemoveLanguage | S V D .h | Removes any language associations for a set of file extensions | 
| RemoveOutputFilter | S V D .h | Removes any output filter associations for a set of file extensions | 
| RemoveType | S V D .h | Removes any content type associations for a set of file extensions | 
AddCharset
Maps the given filename extensions to the specified content charset
Syntax
AddCharset charset extension [extension] [...]Description
   
    AddCharset
   
   directive maps listed filename extensions to the specified  charset.
   
    charset
   
   is the MIME charset parameter of filenames containing
   
    extension
   
   .
This mapping is added to others that are already in force and  overrides
any mappings that already exist for the same
   
    extension
   
   .
  
Example
AddLanguage ja .ja
AddCharset EUC-JP .euc
AddCharset ISO-2022-JP .jis
AddCharset SHIFT_JIS .sjis
   With the above config being applied the document
   
    smth.ja.jis
   
   will
be recognized as a Japanese document with ISO-2022-JP charset
(the same is true for the
   
    xxxx.jis.ja
   
   document).
Using AddCharset directive is beneficial for the client,
as it informs about the character encoding of the document thus
favoring its correct interpretation and output, and for content negotiation,
as the server obtains a possibility to return the document accounting for the client's charset preferences.
  
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
Maps the given filename extensions to the specified encoding type
Syntax
AddEncoding MIME-enc extension [extension] [...]Description
   
    AddEncoding
   
   directive maps listed filename extensions
to the specified encoding type.
   
    MIME-enc
   
   is the MIME encoding to be used for documents containing the
   
    extension
   
   . This mapping is added to others that are already in force and
overrides any mappings that already exist for the same
   
    extension
   
   .
  
Example:
AddEncoding x-gzip .gz
AddEncoding x-compress .Z
   With the above config being applied the filenames containing
   
    .gz
   
   extension to be marked as encoded using
   
    x-gzip
   
   encoding,
and filenames containing the
   
    .Z
   
   extension to be marked
as encoded with
   
    x-compress
   
   .
  
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.
AddHandler
Maps the filename extensions to the specified handler
Syntax
AddHandler handler-name extension [extension] [...]
   
    AddHandler
   
   directive instructs
   
    handler-name
   
   handler
to serve specified
   
    extension(s)
   
   .
This mapping is added to others that are already in force and
overrides any mappings that already exist for the same
   
    extension
   
   .
  
Example
AddHandler cgi-script .cgi
   With the above config being applied 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.
AddInputFilter
Maps filename extensions to the filters that will process client requests
Syntax
AddInputFilter filter[;filter...] extension [extension] [...]
   
    AddInputFilter
   
   directive maps the filename extension
   
    extension
   
   to the filters which will process client requests and POST
input when they are received by the server.
This mapping is merged with others that are already in force and
overrides any mappings that already exist for the same
   
    extension
   
   .
  
If more than one filter is specified, they must be separated by semicolons in the order in which they must process the content.
The fiter and extension arguments are case-insensitive and can be specified with or without a leading dot.
AddLanguage
Maps the given filename extension to the specified content language
Syntax
AddLanguage MIME-lang extension [extension] [...]Description
   
    AddLanguage
   
   directive maps the given filename extension
to the specified content language.
   
    MIME-lang
   
   is the MIME language of filenames containing
   
    extension
   
   .
This mapping is added to others that are already in force and overrides
any mappings that already exist for the same
   
    extension
   
   .
  
Example
AddEncoding x-compress .Z
AddLanguage en .en
AddLanguage fr .fr
   With the above config being applied the document
   
    xxxx.en.Z
   
   will be treated as being a compressed English document
(the same is true for the document
   
    xxxx.Z.en
   
   ).
Although 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 set for the same extension, the last assignment will be applied.
The extension argument is case-insensitive and can be specified with or without a leading dot.
AddOutputFilter
Maps filename extensions to the filters that will process responses from the server.
Syntax
AddOutputFilter filter[;filter...] extension [extension] [...]Description
   
    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 mapping is merged with others that are already in force and
overrides any mappings that already exist for the same
   
    extension
   
   .
  
Example
AddOutputFilter INCLUDES;DEFLATE shtmlIf more than one filter is specified, they must be separated by semicolons and follow in the order 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.
AddType
Maps the given filename extensions to the specified content type.
Syntax
AddType MIME-type extension [extension] [...]Description
   
    AddType
   
   directive  maps the given filename extensions to the specified content type.
   
    MIME-type
   
   is the MIME type to use for filenames containing extension.
This mapping is added to others that are already in force and overrides any
mappings that already exist for the same
   
    extension
   
   .
  
Example
AddType image/gif .gifThe extension argument is case-insensitive and can be specified with or without a leading dot.
DefaultLanguage
Sets all files in the given scope to the specified language.
Syntax
DefaultLanguage MIME-lang
   
    DefaultLanguage
   
   directive informs Helicon Ape of necessity to interpret all files
(that don't have an explicit language extension, e.g. by
   
    
     AddLanguage
    
   
   directive)
in the directive's scope  in the specified
   
    MIME-lang
   
   language.
  
   If no
   
    DefaultLanguage
   
   directive is specified and the file is not
assigned any language extensions by
   
    
     AddLanguage
    
   
   ,
then that file   is considered to have no language attribute.
  
Example
DefaultLanguage enModMimeUsePathInfo
Tells mod_mime to treat path_info components as part of the filename.
Syntax
ModMimeUsePathInfo On|OffDefault
ModMimeUsePathInfo OffDescription
   
    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
   
   , that means that
   
    path_info
   
   component is ignored.
  
It's recommentded to utilize this directive when using virtual file system.
Example
ModMimeUsePathInfo On
   Say you have a request
   
    /bar/foo.shtml
   
   where
   
    /bar
   
   is
Location and
   
    ModMimeUsePathInfo
   
   is
   
    On
   
   .
mod_mime will treat the incoming request   as /bar/foo.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.
  
RemoveCharset
Removes any character set associations for a set of file extensions
Syntax
RemoveCharset extension [extension] [...]Description
   
    RemoveCharset
   
   directive removes any character set associations
for files with  specified
   
    extension(s)
   
   .
This allows
   
    .htaccess
   
   files in subdirectories to undo any associations
inherited from parent directories or server configuration.
  
Example
RemoveCharset .html .shtmlThe extension argument is case-insensitive and can be specified with or without a leading dot.
RemoveEncoding
Removes any content encoding associations for a set of file extensions
Syntax
RemoveEncoding extension [extension] [...]Description
   
    RemoveEncoding
   
   directive  removes any encoding associations
for files with specified
   
    extension(s)
   
   .
This allows .htaccess files in subdirectories to undo any associations
inherited from parent directories or server configuration.
  
Example
#in /foo/.htaccess:
AddEncoding x-gzip .gz
AddType text/plain .asc
<Files *.gz.asc>
RemoveEncoding .gz
</Files>
   With the above config being applied the file
   
    foo.gz
   
   will be considered as gzip encoded file, but
   
    foo.gz.asc
   
   will be considered as unencoded plain text file.
  
   
    Note!
   
   
    RemoveEncoding
   
   directives are processed
after any
   
    
     AddEncoding
    
   
   directives,
so it is possible they may undo the effects of the latter if both occur within the same directory configuration.
  
The extension argument is case-insensitive and can be specified with or without a leading dot.
RemoveLanguage
Removes any language associations for a set of file extensions.
Syntax
RemoveLanguage extension [extension] [...]Description
   
    RemoveLanguage
   
   directive removes any language associations
for files with specified
   
    extension(s)
   
   .
This   allows .htaccess files in subdirectories to undo any associations
inherited from parent directories or server configuration.
  
The extension argument is case-insensitive and can be specified with or without a leading dot.
RemoveOutputFilter
Removes any output filter associations for a set of file extensions
Syntax
RemoveOutputFilter extension [extension] [...]Description
   
    RemoveOutputFilter
   
   directive  removes any output filter
associations for files with the specified
   
    extension(s)
   
   .
This allows .htaccess files in subdirectories to undo any associations
inherited from parent directories or server configuration.
  
Example
RemoveOutputFilter shtmlThe extension argument is case-insensitive and can be specified with or without a leading dot.
RemoveType
Removes any content type associations for a set of file extensions.
Syntax
RemoveType extension [extension] [...]Description
   
    RemoveType
   
   directive removes any MIME type associations
for files  with specified
   
    extension(s)
   
   .
This allows .htaccess files in subdirectories to undo any associations
inherited from parent directories or server configuration.
  
Example
#in /foo/.htaccess:
RemoveType .cgi
   With the above config being applied any special handling of
   
    .cgi
   
   files in
   
    /foo/
   
   directory and any beneath it will be removed.
  
   
    Note!
   
   
    RemoveType
   
   directives are processed
after any
   
    
     AddType
    
   
   directives,
so it is possible they may undo the effects of the
latter if both occur within the same directory configuration.
  
The extension argument is case-insensitive and can be specified with or without a leading dot.