Answer the question
In order to leave comments, you need to log in
Why is nginx giving wrong charset response header?
In the settings of the nginx virtual server, the encoding is set:
server {
listen 80;
server_name example.dev;
root /Users/macbook/sites/example.dev/www;
charset windows-1251;
location / {
....
}
}
user:~ macbook$ curl -I example.dev
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Wed, 02 Dec 2015 12:13:51 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.16
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Answer the question
In order to leave comments, you need to log in
X-Powered-By: PHP/5.6.16
php rewrites the Content-type header
accordingly win-1251 will be only for statics You
look in the php code
if there is still a back server between php and ngnix (for example apache) you also need to check its config
default_charset string
In PHP 5.6 and later, "UTF-8" is the default value and is used as the default encoding for the htmlentities(), html_entity_decode(), and htmlspecialchars() functions if the encoding parameter is not specified. The default_charset value is also used to specify the default encoding for iconv functions if the iconv.input_encoding, iconv.output_encoding, and iconv.internal_encoding configuration options are not set, and for mbstring functions if mbstring.http_input mbstring.http_output mbstring.internal_encoding is not set.
All versions of PHP use this value as the encoding for the standard Content-Type header sent by PHP, unless that header is overridden by a call to the header() function.
It is not recommended to set default_charset to an empty value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question