Darn! I finally got over my problem... so let's get back to the very beginning...
I use apache 2.2.4. I've been using it without a problem for a long time. My needs for apache are very basic: I just need tons of directory listings (indexes) with the ability to follow symbolic links, and ~10 aliases. The files in the directory listings are on my local computer and they usually have "weird" encodings, so I needed to let apache know I need it to use UTF-8 as default charset/encoding. Simple to achieve... or so it seemed: I used to run apache installed via aptitude under /etc/apache2.
In /etc/apache2/apache2.conf there was a line:
Include /etc/apache2/conf.d/
And furthermore, of course,
cat /etc/apache2/conf.d/charset
AddDefaultCharset UTF-8
All was fine until a while ago, when after the last apache2 package update, I realized the AddDefaultCharset directive didn't take effect anymore – no matter what encoding I would have tried to use instead of UTF-8.
First thing I did was go check with the apache documentation... and God saw that it was right! No, wait...
I was playing according to the manual, but somehow things didn't work as expected. I even tried adding the AddDefaultCharset line to /etc/apache2/apache2.conf directly, but to no avail.
Then I looked for an answer in the apache httpd bugs section, on mailing lists, forums... still no result.
Finally, somehow I found the answer (after an hour of frustrated googling)... actually it's not an answer as in: an explanation for why the AddDefaultCharset directive doesn't take effect anymore (this is why I'm labeling this post with "bugs" too), but it's at least a workaround for my problem at hand: my /etc/apache2/apache2.conf needs to have the following line:
IndexOptions Charset=UTF-8
At least now "it works"... I have all directory listings displayed in the UTF-8 encoding, such that all non-Latin content on my server is displayed correctly.
Note #1: Somehow, trying the good ol' AddDefaultCharset directive in apache 1.3 under FreeBSD yields the expected results.
Note #2: Somehow, trying the good ol' AddDefaultCharset directive in apache 2.2.8 (the latest release as of now), compiled from source, still doesn't work.
thanks again luckily i only had to google 1 min and found your post lmao
ReplyDeleteThanks for this article. It now works for me as well. *But* every line that has a non-latin character not misses one space so the date and size fields of that line do no longer match the respective columns. It seems the length of the string is calculated wrongly.
ReplyDeleteAny hint to solve this?
No way, my apache2 served directory listing with utf-8, but I can't get it serve html files with utf-8. It stubbornly sticks to iso-8859-1, no matter what I do on the server conf. The only way I found to solve the problem is add a .htaccess file in the directory and put a 'AddType text/html; charset=utf-8' in it. But I want it to work for the whole server, not only a tree of directories...
ReplyDelete