Sim*_*hke 6 content-negotiation apache-2.2
我试图让MultiViews选项在 Apache 中工作,以根据Accept-Language请求中提供的内容改变返回到浏览器的内容。
我有以下配置:
Alias /multiviewstest "C:/MultiViews Test"
<Directory "C:/MultiViews Test">
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
在我的C:\MultiViews Test目录中,我有以下文件:
spam.htmlfoo.html.en当我请求返回http://localhost/multiviewstest/spam内容时spam.html。以下是请求和响应标头:
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
Run Code Online (Sandbox Code Playgroud)
的Content-Location,Vary和TCN响应头表示MultiViews已经在正确的踢。
我已将英语配置为在浏览器中显示语言的唯一首选语言;的Accept-Language en首部设置的请求。当我请求http://localhost/multiviewstest/foo.html返回 404 响应时。根据我对Apache 语言协商文件命名约定的理解,我希望foo.html.en返回文件的内容。
以下是请求和响应标头:
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
Run Code Online (Sandbox Code Playgroud)
以下是请求的访问日志中显示的内容:
127.0.0.1 - - [04/May/2009:10:28:24 +1200] "GET /multiviewstest/foo.html HTTP/1.1" 404 221
Run Code Online (Sandbox Code Playgroud)
并从错误日志:
[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).
Run Code Online (Sandbox Code Playgroud)
为什么语言的内容协商没有正确启动?有没有我忽略的配置?
您的配置中是否存在正确的语言/扩展关系?
AddLanguage en .en
LanguagePriority en fr de
ForceLanguagePriority Fallback
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2903 次 |
| 最近记录: |