I'm attempting to get the MultiViews
option working in Apache to vary the content returned to the browser based on the Accept-Language
provided in requests.
I've got the following configuration:
Alias /multiviewstest "C:/MultiViews Test"
<Directory "C:/MultiViews Test">
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
In my C:\MultiViews Test
directory I have the following files:
spam.html
foo.html.en
When I request http://localhost/multiviewstest/spam
the contents of spam.html
is returned. Here are the request and response headers:
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Date: Fri, 08 May 2009 11:07:54 GMT
Server: Apache/2.2.10 (Win32)
Content-Location: spam.html
Vary: negotiate
TCN: choice
Last-Modified: Fri, 08 May 2009 10:48:34 GMT
Etag: "0-4-469645ec81e70;469645ff5a5d8"
Accept-Ranges: bytes
Content-Length: 4
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
The Content-Location
, Vary
, and TCN
response headers indicates MultiViews
have correctly kicked in.
I've configured English as the only preferred language for displaying languages in my browser; an Accept-Language en
header is set on requests. When I request http://localhost/multiviewstest/foo.html
a 404 response is returned. Based on my understanding of Apache's file naming conventions for language negotiation I'd expect the contents of the foo.html.en
file to be returned.
Here are the request and response headers:
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Date: Fri, 08 May 2009 11:08:39 GMT
Server: Apache/2.2.10 (Win32)
Content-Length: 221
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
Here's what appears in the access log for the request:
127.0.0.1 - - [04/May/2009:10:28:24 +1200] "GET /multiviewstest/foo.html HTTP/1.1" 404 221
And from the error log:
[Mon May 04 10:28:24 2009] [error] [client 127.0.0.1] Negotiation: discovered file(s) matching request: C:/MultiViews Test/foo.html (None could be negotiated).
Why isn't the content negotiation for the language correctly kicking in? Is there some configuration I have overlooked?