IE8 - 内容不可接受的 Symfony 2 应用程序



我有一个网站正在运行(我需要支持IE8)。

服务器:Nginx,框架Symfony2/PHP/MySQL

问题很简单:IE8 (8.0.6) 显示 HTTP 406内容在所有 HTML 页面上都不可接受的

标头 (nginx)

Cache-Control:no-cache
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Mon, 25 Apr 2016 15:23:46 GMT
Server:nginx/1.6.2
Transfer-Encoding:chunked
X-Debug-Token:d7e68f

HTML (2 个版本,不起作用)

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
    <meta name="robots" content="noindex, nofollow">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Htm 2</title>
    <link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
   ... hi
</body>
</html>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="robots" content="noindex, nofollow">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Htm</title>
    <link rel="icon" type="image/x-icon" href="/favicon.ico" />
</head>
<body>
   ... hi
</body>
</html>

我已经阅读了大量关于这个问题的东西,但找不到任何线索。以前的网站版本适用于IE8并在Apache 2上运行。

此错误与

Nginx 无关,而是与 Symfony 2FOSRESTBundle 有关,后者依赖于客户端标头通过格式侦听器协商响应内容。

溶液:

我更改了我的配置以禁用 FOSRest 以禁用 HTML 页面的格式侦听器。

fos_rest:
    format_listener:
        rules:
            - { path: '^/rest', priorities: [ 'json' ], fallback_format: json, prefer_extension: false }
            #- { path: ^/, priorities: [ 'text/html', '*/*' ], fallback_format: html, prefer_extension: true }
            - { path: '^/', stop: true }

最新更新