Ubuntu / Lighttpd没有为我的UTF-8编码文件提供正确的Content-Type标题。 它发送Content-Type: text/html而不是Content-Type: text/html; charset=UTF-8 Content-Type: text/html; charset=UTF-8 。 我如何configurationLighttpd发送正确的头文件?
我在默认的lighttpd.conf没有看到任何有用的设置,并且在查找文档中的信息时遇到了麻烦。
默认的lighttpd.conf文件似乎使用perl脚本从/etc/mime.types加载MIMEtypes:
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
在我的/etc/mime.types我的html文件已被设置为text/html 。 我注释掉了include_shell perl脚本,并将下面的mimetype.assign条目添加到lighttpd.conf :
mimetype.assign = ( ".html" => "text/html; charset=utf-8" )
我不确定是否有更优雅的解决scheme。 使用这种方法,我需要复制/etc/mime.types中的所有条目以保留其他MIMEtypes映射。
我遇到了同样的问题, 最终在博客上find了解决scheme
基本上它是上面提到的perl脚本的pimped版本,它将charset = utf-8声明添加到以“text /”开头的所有mimetypes。只需replaceperl脚本并重新启动lighttpd即可。
只是添加“““““ charset = utf-8 string' for mimes.conf中的每个“text /”行? 我的意思是:
".css" => "text/css; charset=utf-8", ".html" => "text/html; charset=utf-8", ...