Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

ForceType versus AddType

3:09 pm on Aug 24, 2013 (gmt 0)

Full Member

5+ Year Member Top Contributors Of The Month

joined:Sept 30, 2009
votes: 1

I am trying to understand the difference between ForceType and AddType. They both appear to associate a MIME-type with an extension but ForceType's structure seems more robust.

If I don't need this robustness I'd prefer to use a simple tool for a simple job.

I'd like to have my server treat .html.gz files as text/html, but substituting the second block of code for the first in my .htaccess file causes the browser to stop displaying the page and instead downloads it. I appreciate they are two different blocks of code but I'm not understanding the subtleties between them, or if it is possible to modify the simpler second block of code to accomplish the same job as the first.

<FilesMatch "\.html\.gz$">
ForceType text/html

AddType text/html .html.gz
10:53 pm on Aug 27, 2013 (gmt 0)


WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
votes: 33

AddType will apply to any requested resource with the specified filename extension (within the specified context.)

ForceType will apply to all requested resources (within the specified context.)

<FilesMatch "\.html\.gz$">
ForceType text/html

i'm not sure this would work using a FilesMatch container.

When placed into an .htaccess file or a <Directory>, or <Location> or <Files> section...

if you want to use ForceType and limit it to one filetype i think you would need to use something like the following instead:
<Files ~ "\.html\.gz$">
ForceType text/html

have you verified that the correct Content-Type header is being sent with the response when configured using the AddType directive for .html.gz files?
note that ForceType is a core module directive while AddType is a mod_mime directive.
if mod_mime isn't loaded/enabled the directive won't work.