Lighttpd sending wrong headers for UTF-8 content

Solution 1:

The default lighttpd.conf file seems to load MIME types from /etc/mime.types using a perl script:

include_shell "/usr/share/lighttpd/create-mime.assign.pl"

In my /etc/mime.types my html files had been set to be served as text/html. I commented out the include_shell perl script and added the following mimetype.assign entry to lighttpd.conf:

mimetype.assign = ( ".html" => "text/html; charset=utf-8" )

I'm not sure if there's a more elegant solution. Using this method I would need to copy in all of the entries in /etc/mime.types to retain the other MIME type mappings.

Solution 2:

I was having the very same problem and finally found a solution on a blog

Basically it's a pimped version of above mentioned perl script that adds the charset=utf-8 declaration to all mime-types that start with "text/" Just replace the perl script and restart lighttpd.