Apache Server for Windows Little Black Book:Content Handling With Apache
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Apache Server for Windows Little Black Book
(Publisher: The Coriolis Group)
Author(s): Greg Holden with Matthew Keller
ISBN: 1576103919
Publication Date: 01/01/99
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Chapter 6Content Handling With Apache
If you need an immediate solution to:
Using An Alternate mime.types Location
Adding New File Types With AddType
Forcing A MIME Type In A Directory
Using AddEncoding To Identify Encoded Files
Associating A Handler With A File Type
Using SetHandler For Specific Locations
Specifying Alternate Text For A File Type
Specifying Icons For Selected File Types
Performing An Action On A Type Of File
In Brief
Apache And File Types
The capability to transmit different kinds of information is one of the features that has made the World Wide Web a popular and exciting medium of communication. This capability is made possible by the HTTP protocol, which provides for the negotiation of MIME types. This chapter examines Apache MIME-type directives and other features that allow the Webmaster to control how Apache processes specific kinds of content.
The mime.types File
For Apache to know what action to perform on a file, it needs to know something about whats in that file. This is conveyed by the extension appended to the files name. Apache needs to be told information such as this:
A file whose name ends in .htm or .html is of the MIME type text/html.
A file whose name ends with .jpeg or .jpg is of the MIME type image/jpeg.
A file whose name ends with .txt is of the MIME type plain/text.
Apache stores such information in the mime.types file. This file is located in the C:\Apache\Conf directory along with httpd.conf and the other primary configuration files. If you open mime.types with Notepad or another text editor, youll see that its a simple text file that can be edited like any other. Here is an example of the contents of a mime.types file:
# MIME type Extension
application/activemessage
application/andrew-inset
application/applefile
...
audio/x-realaudio ra
audio/x-wav wav
...
image/gif gif
image/ief ief
image/jpeg jpeg jpg jpe
image/png png
TIP: You can edit the file specified by TypesConfig (by default, this is the file mime.types), and its convenient to do so if youre editing common file types like GIF or JPEG. For unusual file types, however, its better to use AddType, AddHandler, and other directives (which are described later in this chapter) to change Apaches MIME type configuration. Why? Apache is updated on a regular basis, and the mime.types file that is included with the regular distribution of Apache is regularly updated as well. If you make changes to mime.types and install a new version of Apache, a new file called mime.types.default is installed. Your new file type information will still be contained in mime.types, but you wont get the benefit of any new file types that are in mime.types.default.
Apache examines file names for MIME-type information. Encoding and language extensions are removed before the file is processed. The order of the extensions is normally irrelevant. For example, if the file welcome.html.fr maps onto content type text/html and language French, then the file welcome.fr.html will map onto exactly the same information.
The only exception to this is if an extension that Apache does not know how to handle is given. In this case, it will forget about any information it obtained from extensions to the left of the unknown extension. So, for example, if the extensions .fr and .html are mapped to the appropriate language and type, but extension .foo is not assigned to anything, the file welcome.fr.foo.html will be associated with content-type text/html but no language.
If it does not find the last extension (in the previous example, .html), Apache would identify the file as being of the type specified with the DefaultType directive.
Content-Type Modules
Apache can keep track of content types and what actions are to be performed on them primarily through modules whose job is to receive specific types of files, process file types, and perform the denied actions upon them. These modules are discussed in the following sections.
mod_mime
The mod_mime module tells Apache what file-type information to recognize and what actions to perform upon receiving certain file types. Its an essential tool for identifying content so Apache can communicate with clients.
File-Type Information
One function performed by mod_mime is content identification. If Apache can identify a file from its extension, it can then act upon it in some way. For instance, if the server receives the following request from a browser
http://www.company.com/list.txt
it receives the URL and checks mod_mime and the configuration files. It learns that a plain-text file is being requested. It then sends the text file to the browser.
HTTP Header Information
The mod_mime module also adds MIME-type information about a file in the HTTP header it sends to the client. Consider this header:
MIME-Type: audio/ram
It tells the browser that the file is an audio file. The browser checks its own options or preferences files for information on how to handle this file. If the browser has been configured correctly, it will launch the RealAudio plug-in and play the audio file.
Language Information
In many cases, the correct content type of a file can be guessed by looking at the file contents. A new module, mod_mime_magic, does this. It is based on the standard Unix file command, which identifies the type of a file based on examining the first few characters in the file.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
129 09125 gtxt zal1AWM 129 PLrozdzial (129)Eminent 125 SL129 11 (4)1256rozdzial (129)A3 1 8 (125 koni) łancuch125 etxt129@7 pol ed02 2005więcej podobnych podstron