Tuning standard Apache HTTPD for KOI8-R encoding

FYI: I run standard Apache HTTPD on this site.

Если вы не имеете возможности контролировать WWW сервер ваших страничек или не обладаете нужной квалификацией, смотрите простые инструкции по установке кодировки.

To specify character set for your KOI8-R documents, for modern Apache versions (1.3.12 and up) just add

 AddDefaultCharset koi8-r AddCharset koi8-r .css AddType "text/javascript; charset=koi8-r" .js AddLanguage ru .html .htm .shtml .txt .css .js .cgi 
lines to your global httpd.conf file or the local .htaccess file and skip the rest of this paragraph.

To specify character set for your KOI8-R documents, for Apache versions 1.3.10 and up just add

 AddCharset koi8-r .html .htm .shtml .txt .css AddType "text/javascript; charset=koi8-r" .js AddLanguage ru .html .htm .shtml .txt .css .js .cgi 
lines to your global httpd.conf file or the local .htaccess file and skip the rest of this paragraph.

For old Apache versions you can add

 AddType "text/html; charset=koi8-r" .html .htm .shtml AddType "text/plain; charset=koi8-r" .txt AddType "text/css; charset=koi8-r" .css AddType "text/javascript; charset=koi8-r" .js AddLanguage ru .html .htm .shtml .txt .css .js .cgi 
lines to your global srm.conf file or the local .htaccess file.

The server is bound to use charset= parameter; if document character set is not listed in Accept-Charset, the server should respond with the 406 (none acceptable) status code.


Apache Russification Resources

Although, IMHO, any on-the-fly character set conversion and multi-encoding Web server setup are unnecessary for Russian language (KOI8-R must be the only Net character set on the Web as it is in Russian E-mail and News), I put here some resources to give you freedom of choice:

  • Apache .var charset negotiation describes character set negotiation via Apache .var files (mostly theoretical).

  • Multi-charset Cyrillic support for WWW by Eugene Crosser.

  • HTTP server for Russia, aka Apache/RUS, aka Kryukov's Apache.

    WARNING: for newer versions of this server (PL18 and up) be sure that following line present in your config (not commented out):

     CharsetMatchLanguage Off 
    unless you plan to do some complex things with AddLanguage (you may not see charset= parameter in HTTP header without it).

    WARNING: old versions of this server (older than PL15c) are known to be broken for Lynx and Microsoft Internet Explorer browsers, to fix this bug upgrade to the latest Apache-RUS version. As a workaround, replace the following httpd.conf line:

    BadAgent lynx arena DosLynx MSIE

    to

    BadAgent Lynx/2.0 Lynx/2.1 Lynx/2.2 Lynx/2.3 Lynx/2.4 "MSIE 2.0;" Lynx2/OS/2

    (in this case charset= will confuse obsolete (lower than 2.5) Lynx versions and some older MS Internet Explorer versions, but anyway it's the user who is to blame for using them).

    Please note that Lynx not supposed to work with charset=koi8-r if you simple install and not configure it properly. See my Lynx tuning section.