Sending Correct Content-Type Headers with .htaccess

Learn how to set up your mime headers in .htaccess here.


Sample .htaccess file from Mozilla

The developers at Mozilla explain how the purpose of configuring the Apache web server to send many common file types with the correct MIME types

Provided .htaccess file


# CSS
AddType text/css .css

# XHTML
AddType application/xhtml+xml .xhtml

# XML
AddType text/xml .xml

# SVG
AddType image/svg+xml .svg .svgz
AddEncoding x-gzip .svgz

# HTML
# Server Side Includes (SSI)
AddType text/html .shtml

# Active Server Pages
AddType text/html .asp

# Favicons
AddType image/vnd.microsoft.icon .ico

# Macromedia
AddType application/x-shockwave-flash .swf
AddType application/x-director .dir .dcr .dxr .fgd
AddType application/x-authorware-map .aam
AddType application/x-authorware-seg .aas
AddType application/x-authorware-bin .aab
AddType image/x-freehand .fh4 .fh5 .fh7 .fhc .fh

# Adobe PDF
AddType application/pdf .pdf

# Real
AddType application/vnd.rn-realmedia .rm
AddType audio/vnd.rn-realaudio .ra .ram
AddType video/vnd.rn-realvideo .rv
AddType audio/x-pn-realaudio-plugin .rpm

# Microsoft multimedia
AddType video/x-ms-asf .asf .asx
AddType audio/x-ms-wma .wma
AddType audio/x-ms-wax .wax
AddType video/x-ms-wmv .wmv
AddType video/x-ms-wvx .wvx
AddType video/x-ms-wm .wm
AddType video/x-ms-wmx .wmx
AddType application/x-ms-wmz .wmz
AddType application/x-ms-wmd .wmd

# MPEG
AddType audio/x-mpegurl .m3u

# Binary Compressed files and archives
AddType application/zip .zip
AddType application/x-gzip .gz
AddType application/x-gtar .gtar
AddType application/x-rar-compressed .rar
AddType application/octet-stream .dmg

# Java
AddType application/x-java-applet .class

# Quicktime movies
AddType video/quicktime .mov .qt

# XBM files
AddType image/x-xbitmap .xbm

# WAV files
AddType audio/x-wav .wav

# Bittorrent
AddType application/x-bittorrent .torrent

Common file extensions

that are good to know, organized by file format.

.doc Microsoft Word Document
.log Log File
.msg Mail Message
.rtf Rich Text Format File
.txt Text File
.wpd WordPerfect Document
.wps Microsoft Works Word Processor Document
.123 Lotus 1-2-3 Spreadsheet
.csv Comma Separated Values File
.dat Data File
.db Database File
.dll Dynamic Link Library
.mdb Microsoft Access Database
.pps PowerPoint Slide Show
.ppt PowerPoint Presentation
.sql Structured Query Language Data
.wks Microsoft Works Spreadsheet
.xls Microsoft Excel Spreadsheet
.xml XML File



Posted

in

by

Comments

2 responses to “Sending Correct Content-Type Headers with .htaccess”

  1. Phil Avatar
    Phil

    Thanks, exactly what I needed!

    Like

  2. Pedro Cunha Avatar
    Pedro Cunha

    Thanks, that was exactly what I was looking for.

    Keep up the good work!

    Like

Leave a comment