1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>mod_negotiation - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.0</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.0</a> > <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_negotiation</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_negotiation.html" title="English"> en </a> |
25 <a href="../ja/mod/mod_negotiation.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
27 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for <a href="../content-negotiation.html">content negotiation</a></td></tr>
28 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
29 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>negotiation_module</td></tr>
30 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_negotiation.c</td></tr></table>
33 <p>Content negotiation, or more accurately content selection, is
34 the selection of the document that best matches the clients
35 capabilities, from one of several available documents. There
36 are two implementations of this.</p>
39 <li>A type map (a file with the handler
40 <code>type-map</code>) which explicitly lists the files
41 containing the variants.</li>
43 <li>A MultiViews search (enabled by the <code>MultiViews</code>
44 <code class="directive"><a href="../mod/core.html#options">Options</a></code>), where the server does
45 an implicit filename pattern match, and choose from amongst the
49 <div id="quickview"><h3 class="directives">Directives</h3>
51 <li><img alt="" src="../images/down.gif" /> <a href="#cachenegotiateddocs">CacheNegotiatedDocs</a></li>
52 <li><img alt="" src="../images/down.gif" /> <a href="#forcelanguagepriority">ForceLanguagePriority</a></li>
53 <li><img alt="" src="../images/down.gif" /> <a href="#languagepriority">LanguagePriority</a></li>
57 <li><img alt="" src="../images/down.gif" /> <a href="#typemaps">Type maps</a></li>
58 <li><img alt="" src="../images/down.gif" /> <a href="#multiviews">MultiViews</a></li>
59 </ul><h3>See also</h3>
61 <li><code class="directive"><a href="../mod/core.html#options">Options</a></code></li>
62 <li><code class="module"><a href="../mod/mod_mime.html">mod_mime</a></code></li>
63 <li><a href="../content-negotiation.html">Content
65 <li><a href="../env.html">Environment Variables</a></li>
67 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
69 <h2><a name="typemaps" id="typemaps">Type maps</a></h2>
70 <p>A type map has a format similar to RFC822 mail headers. It
71 contains document descriptions separated by blank lines, with
72 lines beginning with a hash character ('#') treated as
73 comments. A document description consists of several header
74 records; records may be continued on multiple lines if the
75 continuation lines start with spaces. The leading space will be
76 deleted and the lines concatenated. A header record consists of
77 a keyword name, which always ends in a colon, followed by a
78 value. Whitespace is allowed between the header name and value,
79 and between the tokens of value. The headers allowed are: </p>
82 <dt><code>Content-Encoding:</code></dt>
83 <dd>The encoding of the file. Apache only recognizes
84 encodings that are defined by an <code class="directive"><a href="../mod/mod_mime.html#addencoding">AddEncoding</a></code> directive.
85 This normally includes the encodings <code>x-compress</code>
86 for compress'd files, and <code>x-gzip</code> for gzip'd
87 files. The <code>x-</code> prefix is ignored for encoding
90 <dt><code>Content-Language:</code></dt>
91 <dd>The language(s) of the variant, as an Internet standard
92 language tag (<a href="http://www.ietf.org/rfc/rfc1766.txt">RFC 1766</a>). An example is <code>en</code>,
93 meaning English. If the variant contains more than one
94 language, they are separated by a comma.</dd>
96 <dt><code>Content-Length:</code></dt>
97 <dd>The length of the file, in bytes. If this header is not
98 present, then the actual length of the file is used.</dd>
100 <dt><code>Content-Type:</code></dt>
103 The MIME media type of the document, with optional
104 parameters. Parameters are separated from the media type
105 and from one another by a semi-colon, with a syntax of
106 <code>name=value</code>. Common parameters include:
109 <dt><code>level</code></dt>
110 <dd>an integer specifying the version of the media type.
111 For <code>text/html</code> this defaults to 2, otherwise
114 <dt><code>qs</code></dt>
115 <dd>a floating-point number with a value in the range 0.0
116 to 1.0, indicating the relative 'quality' of this variant
117 compared to the other available variants, independent of
118 the client's capabilities. For example, a jpeg file is
119 usually of higher source quality than an ascii file if it
120 is attempting to represent a photograph. However, if the
121 resource being represented is ascii art, then an ascii
122 file would have a higher source quality than a jpeg file.
123 All <code>qs</code> values are therefore specific to a given
127 <div class="example"><h3>Example</h3><p><code>
128 Content-Type: image/jpeg; qs=0.8
132 <dt><code>URI:</code></dt>
133 <dd>uri of the file containing the variant (of the given
134 media type, encoded with the given content encoding). These
135 are interpreted as URLs relative to the map file; they must
136 be on the same server (!), and they must refer to files to
137 which the client would be granted access if they were to be
138 requested directly.</dd>
140 <dt><code>Body:</code></dt>
141 <dd>New in Apache 2.0, the actual content of the resource may
142 be included in the type-map file using the Body header. This
143 header must contain a string that designates a delimiter for
144 the body content. Then all following lines in the type map
145 file will be considered part of the resource body until the
146 delimiter string is found.
148 <div class="example"><h3>Example:</h3><p><code>
149 Body:----xyz----<br />
152 <p>Content of the page.</p><br />
159 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
160 <div class="section">
161 <h2><a name="multiviews" id="multiviews">MultiViews</a></h2>
162 <p>A MultiViews search is enabled by the <code>MultiViews</code>
163 <code class="directive"><a href="../mod/core.html#options">Options</a></code>. If the server receives a
164 request for <code>/some/dir/foo</code> and
165 <code>/some/dir/foo</code> does <em>not</em> exist, then the
166 server reads the directory looking for all files named
167 <code>foo.*</code>, and effectively fakes up a type map which
168 names all those files, assigning them the same media types and
169 content-encodings it would have if the client had asked for one
170 of them by name. It then chooses the best match to the client's
171 requirements, and returns that document.</p>
173 <p>The <code class="directive"><a href="../mod/mod_mime.html#multiviewsmatch">MultiViewsMatch</a></code>
174 directive configures whether Apache will consider files
175 that do not have content negotiation meta-information assigned
176 to them when choosing files.</p>
178 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
179 <div class="directive-section"><h2><a name="CacheNegotiatedDocs" id="CacheNegotiatedDocs">CacheNegotiatedDocs</a> <a name="cachenegotiateddocs" id="cachenegotiateddocs">Directive</a></h2>
180 <table class="directive">
181 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Allows content-negotiated documents to be
182 cached by proxy servers</td></tr>
183 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheNegotiatedDocs On|Off</code></td></tr>
184 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheNegotiatedDocs Off</code></td></tr>
185 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
186 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
187 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_negotiation</td></tr>
188 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>The syntax changed in version 2.0.</td></tr>
190 <p>If set, this directive allows content-negotiated documents
191 to be cached by proxy servers. This could mean that clients
192 behind those proxys could retrieve versions of the documents
193 that are not the best match for their abilities, but it will
194 make caching more efficient.</p>
196 <p>This directive only applies to requests which come from
197 HTTP/1.0 browsers. HTTP/1.1 provides much better control over
198 the caching of negotiated documents, and this directive has no
199 effect in responses to HTTP/1.1 requests.</p>
201 <p>Prior to version 2.0,
202 <code class="directive">CacheNegotiatedDocs</code> did not take an
203 argument; it was turned on by the presence of the directive by
207 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
208 <div class="directive-section"><h2><a name="ForceLanguagePriority" id="ForceLanguagePriority">ForceLanguagePriority</a> <a name="forcelanguagepriority" id="forcelanguagepriority">Directive</a></h2>
209 <table class="directive">
210 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Action to take if a single acceptable document is not
212 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ForceLanguagePriority None|Prefer|Fallback [Prefer|Fallback]</code></td></tr>
213 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>ForceLanguagePriority Prefer</code></td></tr>
214 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
215 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
216 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
217 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_negotiation</td></tr>
218 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later</td></tr>
220 <p>The <code class="directive">ForceLanguagePriority</code> directive uses
221 the given <code class="directive"><a href="#languagepriority">LanguagePriority</a></code> to satisfy
222 negotation where the server could otherwise not return a single
223 matching document.</p>
225 <p><code>ForceLanguagePriority Prefer</code> uses
226 <code>LanguagePriority</code> to serve a one valid result, rather
227 than returning an HTTP result 300 (MULTIPLE CHOICES) when there
228 are several equally valid choices. If the directives below were
229 given, and the user's <code>Accept-Language</code> header assigned
230 <code>en</code> and <code>de</code> each as quality <code>.500</code>
231 (equally acceptable) then the first matching variant, <code>en</code>,
234 <div class="example"><p><code>
235 LanguagePriority en fr de<br />
236 ForceLanguagePriority Prefer
239 <p><code>ForceLanguagePriority Fallback</code> uses
240 <code class="directive"><a href="#languagepriority">LanguagePriority</a></code> to
241 serve a valid result, rather than returning an HTTP result 406
242 (NOT ACCEPTABLE). If the directives below were given, and the user's
243 <code>Accept-Language</code> only permitted an <code>es</code>
244 language response, but such a variant isn't found, then the first
245 variant from the <code class="directive"><a href="#languagepriority">LanguagePriority</a></code> list below will be served.</p>
247 <div class="example"><p><code>
248 LanguagePriority en fr de<br />
249 ForceLanguagePriority Fallback
252 <p>Both options, <code>Prefer</code> and <code>Fallback</code>, may be
253 specified, so either the first matching variant from <code class="directive"><a href="#languagepriority">LanguagePriority</a></code> will be served if
254 more than one variant is acceptable, or first available document will
255 be served if none of the variants matched the client's acceptable list
260 <li><code class="directive"><a href="../mod/mod_mime.html#addlanguage">AddLanguage</a></code></li>
263 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
264 <div class="directive-section"><h2><a name="LanguagePriority" id="LanguagePriority">LanguagePriority</a> <a name="languagepriority" id="languagepriority">Directive</a></h2>
265 <table class="directive">
266 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The precendence of language variants for cases where
267 the client does not express a preference</td></tr>
268 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LanguagePriority <var>MIME-lang</var> [<var>MIME-lang</var>]
270 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
271 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
272 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
273 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_negotiation</td></tr>
275 <p>The <code class="directive">LanguagePriority</code> sets the precedence
276 of language variants for the case where the client does not
277 express a preference, when handling a MultiViews request. The list
278 of <var>MIME-lang</var> are in order of decreasing preference.</p>
280 <div class="example"><h3>Example:</h3><p><code>
281 LanguagePriority en fr de
284 <p>For a request for <code>foo.html</code>, where
285 <code>foo.html.fr</code> and <code>foo.html.de</code> both
286 existed, but the browser did not express a language preference,
287 then <code>foo.html.fr</code> would be returned.</p>
289 <p>Note that this directive only has an effect if a 'best'
290 language cannot be determined by any other means or the <code class="directive"><a href="#forcelanguagepriority">ForceLanguagePriority</a></code> directive
291 is not <code>None</code>. In general, the client determines the
292 language preference, not the server.</p>
296 <li><code class="directive"><a href="../mod/mod_mime.html#addlanguage">AddLanguage</a></code></li>
300 <div class="bottomlang">
301 <p><span>Available Languages: </span><a href="../en/mod/mod_negotiation.html" title="English"> en </a> |
302 <a href="../ja/mod/mod_negotiation.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
303 </div><div id="footer">
304 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
305 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>