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

时间:2016-05-23 11:38:49

标签: internet-explorer nginx mediawiki

我正在运行带有短网址配置的Mediawiki(example.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响应标头中的content-type和charset似乎是正确的:

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

1 个答案:

答案 0 :(得分:0)

这个问题似乎来自多次尝试gzip内容,因此http头中的双gzip。

content-encoding: gzip, gzip

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

fastcgi_param   HTTP_ACCEPT_ENCODING "";