Configuring Content Negotiation


Options +Multiviews AddHandler type-map .var


There are two primary ways of configuring content negotiation in Apache: multiviews and type maps.

Multiviews can be enabled by adding an Options +Multiviews directive to your configuration. This method is not recommended (except for simple websites) because it is not very efficient: For every request, it scans the directory containing the file, looking for similar documents with additional extensions. It will then construct a list of such files and use the extensions to determine content encoding and character set, and return the appropriate content.

It is recommended that you use type maps instead, because they save filesystem lookups. These are special files that map filenames and information (metadata) about them. You can configure a type map for a certain resource by creating a file with the same name and the .var extension, and adding an AddHandler directive, as shown in the sample configuration.

The file can contain several entries. Each entry starts with a URI: that is the name of the document, followed by several attributes such as Content-Type:, Content-Language:, and Content-Encoding:. The following listing shows a sample type map file.

Listing 4.1. Contents of Type Map File

URI: page.html.en Content-type: text/html Content-language: en URI: page.html.fr Content-type: text/html; charset=iso-8859-2 Content-language: fr

Tip

Bear in mind that using any kind of content-negotiation has an adverse impact on the performance of the web server, as it requires additional filesystem accesses.





Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net