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

Apache Web Server Forum

    
ForceType versus AddType
ocon




msg:4604690
 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
</FilesMatch>

AddType text/html .html.gz

 

phranque




msg:4605280
 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
</FilesMatch>


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

http://httpd.apache.org/docs/current/mod/core.html#forcetype
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
</Files>



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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved