5.12. Associating Files with MIME Types

Servers typically have a way for Webmasters to associate file extensions with media types. So, for example, a file named mom.jpg would automatically be given a MIME type of image/jpeg. However, suppose that your Web application has unusual files that you want to guarantee are assigned a certain MIME type when sent to clients. The mime-mapping element, with extension and mime-type subelements, can provide this guarantee. For example, the following code instructs the server to assign a MIME type of application/x-fubar to all files that end in.foo.

<mime-mapping> 
  <extension>foo</extension> 
  <mime-type>application/x-fubar</mime-type> 
</mime-mapping> 

Or, perhaps your Web application wants to override standard mappings. For instance, the following would tell the server to designate.ps files as plain text (text/plain) rather than as PostScript (application/postscript) when sending them to clients.

<mime-mapping> 
  <extension>ps</extension> 
  <mime-type>text/plain</mime-type> 
</mime-mapping> 

For more information on MIME types, see Table 2.1 on page 88.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.37.12