Site Encoding Siddenly Went Wrong, Response Header Shows Wrong Encoding

Few days ago I’ve noticed that some old sites on my server started to show pages in wrong encoding. I can switch encoding manually for each page, but when following a link I’m getting wrong charset again. This happens even on sites where right proper encoding is explicitly set on each page in meta tag.

I’ve found that the problem is the default charset of php encoding, set on php settings of server, starting from php version 5.6.0, as pointed on this PHP documentation page.

default_charset “UTF-8” PHP_INI_ALL Default to “UTF-8” since PHP >= 5.6.0, empty for PHP < 5.6.0.

My server had silently updated its php version and I’ve got default charset iso-8859-1 set in the HTTP header.

But: the HTTP header has a higher precedence than the in-document charset declaration, so all text became unreadable on sites where no header was declared explicitly. I.e. meta tag charset declaration has lower priority over server’s HTTP header.

So just go to WHM and remove default charset iso-8859-1 in Advanced editor Home » Service Configuration » PHP Configuration Editor if you got many old sites with different non-utf-8 encoding. All sites are ok now.


There are more ways to manipulate HTTP header per site, but I’ve got too many, so better to remove, until I have all sites in UTF-8. Than I’ll put default_charset to UTF-8.

This entry was posted in Hosting Server and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *