使用 NGINX 服务器,Internet Explorer/Google Search Console 显示乱码

Using NGINX server, Internet Explorer/Google Search Console shows gibberish

我是 运行 具有短 URL 配置的 Mediawiki(示例。com/Page_Title)

location ~ \.htaccess {
    deny all;
}

location / {
    try_files $uri $uri/ @rewrite;
}

location @rewrite {
    rewrite ^/(.*)$ /index.php;
}

location ^~ /maintenance/ {
    return 403;
}

location ^~ /cache/ {
    deny all;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    try_files $uri /index.php;
    expires max;
    log_not_found off;
}

location ~ \.php$ {
    include /etc/nginx/fastcgi_params;

    fastcgi_pass    127.0.0.1:9000;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;

    try_files $uri @rewrite;
}

Chrome 并且 Firefox 渲染得很好,但为什么它在 IE 或 Google Search Console 上显示为乱码,如下所示:��~����=��r6���� � 等等。 运行 测试 .html 或 .php 看起来不错,只有重写的 Mediawiki 页面显示乱码。

来自 HTTP 响应 header 的 content-type 和字符集似乎是正确的:

Response Headers
cache-control: private, must-revalidate, max-age=0
content-encoding: gzip, gzip
content-language: en
content-type: text/html; charset=UTF-8
date: Mon, 23 May 2016 11:32:39 GMT
expires: Thu, 01 Jan 1970 00:00:00 GMT
last-modified: Mon, 23 May 2016 11:02:34 GMT
server: nginx
vary: Accept-Encoding, Cookie, Accept-Encoding
x-content-type-options: nosniff, nosniff
x-frame-options: SAMEORIGIN
x-powered-by: HHVM/3.11.1
x-ua-compatible: IE=Edge, IE=Edge
x-xss-protection: 1; mode=block

问题似乎是由于多次尝试对内容进行 gzip 压缩,因此在 http header.

中出现了双重 gzip
content-encoding: gzip, gzip

在 nginx 配置中添加此参数解决了问题。

fastcgi_param   HTTP_ACCEPT_ENCODING "";