6.2. Content Negotiation
There may be different ways to handle the data that Apache returns, and there are two equivalent ways of implementing this functionality. The multiviews method is simpler (and more limited) than the *.var method, so we shall start with it. The Config file (from ... /site.multiview) looks like this:
User webuser Group webgroup ServerName www.butterthlies.com DocumentRoot /usr/www/site.multiview/htdocs ScriptAlias /cgi-bin /usr/www/cgi-bin AddLanguage it .it AddLanguage en .en AddLanguage ko .ko LanguagePriority it en ko <Directory /usr/www/site.multiview/htdocs> Options +MultiViews </Directory>
For historical reasons, you have to say:
even though you might reasonably think that Options All would cover the case. The general idea is that whenever you want to offer variants on a file (e.g., JPG, GIF, or bitmap for images, or different languages for text), multiviews will handle it.
6.2.1. Image Negotiation
Image negotiation is a special corner of general content negotiation because the Web has a problem with image files: for instance, some browsers can cope with PNG files and some can't, and the latter have to be sent the simpler, more old-fashioned, and bulkier GIF files. The client's browser sends a message to the server telling it which image files it accepts:
HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
The server then looks for an appropriate file and returns it. We can demonstrate the effect by editing our ... /htdocs/catalog_summer.html file to remove the .jpg extensions on the image files. The appropriate lines now look like this:
... <img src="bench" alt="Picture of a Bench"> ... <img src="hen" alt="Picture of a hencoop like a pagoda"> ...
When Apache has the multiViews option turned on and is asked for an image called bench, it looks for the smaller of bench.jpg and bench.gif -- assuming the client's browser accepts both, of course -- and returns it.
Copyright © 2001 O'Reilly & Associates. All rights reserved.