homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

ForceType versus AddType

5+ Year Member

Msg#: 4604688 posted 3:09 pm on Aug 24, 2013 (gmt 0)

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



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

Msg#: 4604688 posted 10:53 pm on Aug 27, 2013 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved