### Apache HTTP Server Version 1.3

# Module mod_mime

This module is contained in the `mod_mime.c` file, and is compiled in by default. It provides for determining the types of files from the filename.

## Summary

This module is used to determine various bits of "meta information" about documents. This information relates to the content of the document and is returned to the browser or used in content-negotiation within the server. In addition, a "handler" can be set for a document, which determines how the document will be processed within the server.

The directives AddEncoding, AddHandler, AddLanguage and AddType are all used to map file extensions onto the meta-information for that file. Respectively they set the content-encoding, handler, content-language and mime-type (content-type) of documents. The directive TypesConfig is used to specify a file which also maps extensions onto mime types. The directives ForceType and SetHandler are used to associated all the files in a given location (e.g. a particular directory) onto a particular mime type or handler.

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 language French then the file `welcome.fr.html` will map onto exactly the same information. The only exception to this is if an extension is given which Apache does not know how to handle. In this case it will "forget" about any information it obtained from extensions to the left of the unknown extension. So, 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.

Note that changing the type or encoding of 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.

Please note that changing a file's type or encoding does not change the value of the `Last-Modified` header. Previously cached copies may still be used by a client or proxy.

## Directives

- AddEncoding
- AddHandler
- AddLanguage
- AddType
- ForceType
- SetHandler
- TypesConfig

## AddEncoding

Syntax: AddEncoding mime-enc extension extension...
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_mime

The AddEncoding directive adds to the list of filename extensions which filenames may end in for the specified encoding type. Mime-enc is the mime encoding to use for documents ending in extension. Example:

> `AddEncoding x-gzip gz
> AddEncoding x-compress Z`

This will cause files ending in .gz to be marked as encoded using the x-gzip encoding, and .Z files 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-`.

## AddHandler

Syntax: AddHandler handler-name extension extension...
Context: server config, virtual host, directory, .htaccess
Status: Base
Module: mod_mime
Compatibility: AddHandler is only available in Apache 1.1 and later

AddHandler maps the filename extensions extension to the handler handler-name. For example, to activate CGI scripts with the file extension "`.cgi`", you might use:

        AddHandler cgi-script cgi

Once that has been put into your srm.conf or httpd.conf file, any file ending with "`.cgi`" will be treated as a CGI program.

## AddLanguage

Syntax: AddLanguage mime-lang extension extension...
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_mime

The AddLanguage directive adds to the list of filename extensions which filenames may end in for the specified content language. Mime-lang is the mime language of files with names ending extension, after any content encoding extensions have been removed. Example:

> `AddEncoding x-compress Z
> AddLanguage en .en
> AddLanguage fr .fr
> `

Then the document `xxxx.en.Z` will be treated as being a compressed English document. 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.

## AddType

Syntax: AddType mime-type extension extension...
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_mime

The AddType directive adds to the list of filename extensions which filenames may end in for the specified content type. Mime-enc is the mime type to use for documents ending in extension. after content-encoding and language extensions have been removed. Example:

> `AddType image/gif GIF`

It is recommended that new mime types be added using the AddType directive rather than changing the TypesConfig file.

Note that, unlike the NCSA httpd, this directive cannot be used to set the type of particular files.

## ForceType

Syntax: ForceType media type
Context: directory, .htaccess
Status: Base
Module: mod_mime
Compatibility: ForceType is only available in Apache 1.1 and later.

When placed into an `.htaccess` file or a `<Directory>` or `<Location>` section, this directive forces all matching files to be served as the content type given by media type. For example, if you had a directory full of GIF files, but did not want to label them all with ".gif", you might want to use:

        ForceType image/gif

Note that this will override any filename extensions that might determine the media type.

## SetHandler

Syntax: SetHandler handler-name
Context: directory, .htaccess
Status: Base
Module: mod_mime
Compatibility: SetHandler is only available in Apache 1.1 and later.

When placed into an `.htaccess` file or a `<Directory>` or `<Location>` section, this directive forces all matching files to be parsed through the handler given by handler-name. For example, if you had a directory you wanted to be parsed entirely as imagemap rule files, regardless of extension, you might put the following into an `.htaccess` file in that directory:

        SetHandler imap-file

Another example: if you wanted to have the server display a status report whenever a URL of `http://servername/status` was called, you might put the following into access.conf:

        <Location /status>
        SetHandler server-status
        </Location>

## TypesConfig

Syntax: TypesConfig filename
Default: `TypesConfig conf/mime.types`
Context: server config
Status: Base
Module: mod_mime

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

The extensions are lower-cased. Blank lines, and lines beginning with a hash character (`#') are ignored.

### Apache HTTP Server Version 1.3