Ubuntu/Lighttpd is not serving my UTF-8 encoded files with the correct Content-Type
header. It's sending Content-Type: text/html
rather than Content-Type: text/html; charset=UTF-8
. How do I configure Lighttpd to send the correct headers?
I didn't see any useful settings in the default lighttpd.conf
and am having trouble finding information in the documentation.
The default
lighttpd.conf
file seems to load MIME types from/etc/mime.types
using a perl script:In my
/etc/mime.types
myhtml
files had been set to be served astext/html
. I commented out theinclude_shell
perl script and added the following mimetype.assign entry tolighttpd.conf
: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.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.
It isn't cleaner to just add the `; charset=utf-8 string´ for each "text/" line in mimes.conf? I mean like: