Wrong default encoding on the Apache webserver
Published on 2007-08-22.
This is a mini tutorial in solving problems with the Apache webserver encoding specifications.
By default the Apache directive
AddDefaultCharset is set to
Off which means that the encoding of the webpage is set by the HTML
Normally you set the default encoding with HTML in the
META tags like this:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Or with HTML5 like this:
A problem can occur if your Apache webserver or PHP installation is not configured properly in which the Apache webserver still uses the ISO-8859-1 encoding rather than UTF-8 or something else.
To fix this you can either change the directive
UTF-8 in your
httpd.conf configuration file like this:
In which case the default encoding of Apache will be UTF-8.
You can also change the directive
OFF in your
httpd.conf configuration file:
And then handle all encoding from HTML. Make sure that the mimetype and charset directives of PHP is set correctly in
php.ini, if you're using PHP.
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 encoding you specify in the
Another options is to add this to your
.htaccess in case you have access to it:
This will also set the default encoding of Apache to UTF-8.
If you have any comments or corrections please feel free to email them to me. Also, if you found this content useful consider supporting me on Patreon