Webserver overriding page encoding? Webserver overriding page encoding? apache apache

Webserver overriding page encoding?


After much struggling, a kind soul helped me realize that it's not Apache overriding the charset in the header but PHP itself.

Adding

header('Content-Type: text/html; charset=windows-1255');

to the top of the PHP file fixed the problem.

As far as I understand the chain is as follows:

  1. By default, Apache sends the content with a UTF-8 header
  2. If another charset is set in .htaccess, the browser accepts it
  3. Then comes PHP and forces the charset in the header as specified by default_charset in php.ini

Anything you define before the page reaches the browser in ignored.