Example: how to redefine the encoding of html documents


We want to "explain" to the web server that all html documents that are hosted on the server should be "given" to the client in koi8-r encoding, and not in windows-1251, as the server does by default. To do this, put the line in .htaccess:


AddType "text/html; charset=koi8-r" .html .htm .shtml

Having received such a .htaccess, the Apache web server will issue a header to the client browser, which will indicate that the document has the koi8-r encoding.


If html documents in different encodings exist on your resource (ISO-8859-1, Windows-1250, Windows-1252, UTF-8), then you may need to disable the forced output of the header with the windows-1251 encoding. To do this, a string is added to .htaccess:


AddDefaultCharset Off

In this case, the corresponding encoding should be written on each html page in the form of a tag


These are examples of the simplest use of Apache configuration capabilities via the .htaccess file.


More options:
DefaultLanguage ru
AddDefaultCharset windows-1251
php_value default_charset "cp1251"