Wrong default charset on the Apache webserver

Posted on 22.08.2007 by Kim N. Lesmer.
This is a mini tutorial in solving problems with the Apache webserver charset specifications.

By default the Apache directive AddDefaultCharset is set to Off which means that the encoding of the webpage is set by the META tags.

Normally you set the default charset with in the META tags like this:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

A problem can occur if your Apache webserver or php installation is not configured proberly in which the Apache webserver keeps using the ISO-8859-1 charset rather than UTF-8 or something else.

To fix this you have to do the following.

Make sure that the directive AddDefaultCharset is set to Off by default in you httpd.conf like this:

AddDefaultCharset Off

Make sure that the mimetype and charset directives of php is set correctly in php.ini

The directive:

default_mimetype = "text/html"
default_charset = "iso-8859-1"

Should be changed to:

default_mimetype = ""
default_charset = ""

From this point forward your pages should be rendered as whatever charset you specify in the META tags.