utf-8
I had some drama validating W3C XHTML and CSS2 but that was nothing compared to the Apache2 config to support UTF-8. Here is a quick summary of how I did it on SUSE Enterprise Linux 9 SP3 with Apache2.
I wanted to serve validated XHTML so if you refer to the official guide from the w3c HTML Compatibility Guidelines, you get an HTML template that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Unicode rocks</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</head>
<body>
</body>
</html>
That is all well and good and it validates however, according to the W3C Head service, the Apache2 server built in to SLES9 was still serving up good old ISO-8859-1 headers. Searching for how to get Apache to play the UTF-8 game, I found advice that recommended creating a .htaccess file in the /srv/www/htdocs directory and then add a line:
AddCharset UTF-8 .html .htm .txt
This is intended to serve UTF-8 headers when reading HTML, HTM or TXT files from that directory on the server. However, this didn't work for me and googling for apache advice didn't help. After a bit of fiddling, I found that tweaking the mod_mime-defaults.conf file works a treat:
vi /etc/apache2/mod_mime-defaults.conf
And change the line that says:
AddDefaultCharset ISO-8859-1
to this:
AddDefaultCharset UTF-8
Easy! This changes the entire site to serve UTF-8 HTML headers which may, or may not be desirable for you. If this is not a problem, restart apache using:
/etc/init.d/apache2 restart
Test and validate, sweet as...




