Apache 2.4.20 and AddDefaultCharset

Moderator: cah

Post Reply
cah
General of the Army / Fleet Admiral / General of the Air Force
General of the Army / Fleet Admiral / General of the Air Force
Posts: 1342
Joined: Sun Aug 17, 2008 5:05 am

Apache 2.4.20 and AddDefaultCharset

Post by cah »

After switching to Apache 2.4.20, I realized the default character set became UTF-8. Many of my web pages can no longer show traditional Chinese properly. I have to choose the encoding manually to view the Chinese characters.

I swtiched back to Apache 2.2.14 and everything worked fine.

I did some comparison and found "AddDeafultCharset" was not set in Apache 2.4.20 so I added it in config file(s) but that didn't help.

I then compared the linked shared objects between Apache 2.2.14 and 2.4.20. I found libiconv.so.2 was not linked in Apache 2.4.20's httpd. So, I recompiled APR-UTIL to include iconv:

Code: Select all

./configure --with-apr=/usr/local/apr --with-iconv=/usr/local CFLAGS=-std=gnu99
make
make test
make install
I then recompile Apache 2.4.20:

Code: Select all

./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-cgi --enable-so --with-pcre=/usr/local --with-proxy --enable-dav --enable-modules=all
make
make install
After that, I could see libiconv.so.2 be linked to httpd.

However, it still doesn't work after restarting apache 2.4.20.

I used HTTP / HTTPS header check (http://www.webconfs.com/http-header-check.php) and found the charset is still set as UTF-8 no matter how I change in Apache config file(s).

After numerous tests, I finally got it to work! The following lines need to be added to config file (I added to <VirtualHost> in conf/extra/httpd-vhosts.conf):

Code: Select all

    AddDefaultCharset big5
    ForceType text/html
I then tried the above in httpd.conf under <Directory "/export/home/www/html"> and for static pages, traditional Chinese characters show up correctly. However, that broke phpbb3 (http://bbs.hsiao.net). Maybe phpbb3 cannot have ForceType because of its design.

Also, even though I tested with the following meta tag in testing html files before today's config change and failed, some other virtual hosts without the above settings but with the following meta tag would show traditional Chinese just fine.

Code: Select all

<meta http-equiv="content-type" content="text/html; charset=Big5">
Still puzzled.....
CAH, The Great
Post Reply