University of Southern California

ITS Information Technology Services

Defining Document Types


If a Web browser is not displaying/processing a file correctly, it may be that it does not recognize the file type (MIME type). This often happens with files that require a browser plugin to display correctly, or with files designed to be downloaded for use with another application such as Microsoft Excel.

You can help browsers identify the file type by using an AddType Directive in a .htaccess file.

The AddType directive

This command allows you to add entries to the server's default typing information and cause a filename extension to indicate a certain type of file. These directives override any conflicting entries in the server's default MIME Types file.

Syntax: AddType type/subtype extension

type/subtype is the MIME type for the document.

extension is the filename extension to map to this type.

Example

Suppose you want to include a Shockwave Director Movie (called 'mymovie.dcr') on your web page. In order for people to be able to see it in their browsers, their browsers will need to know that it is an application/x-director type file.

In the same directory as the 'mymovie.dcr' file, you would need a .htaccess file with the following line in it:

AddType application/x-director dcr

Finding the MIME Type

The appropriate MIME Type for a non-standard file can be found in documentation for the application required to generate the file, or the plugin required to view the file. Note that some documentation will instruct you to contact the server administrator and ask that the MIME type be included in the server's configuration file. This is not necessary. You may use as many AddType directives as you wish. Each command should appear on a separate line in the .htaccess file.

Last updated:
June 21, 2007

Web Publishing Documentation

The use of all USC computing resources is governed by the USC Computing Policies.