Apache2 changing charset using .htaccess

If you do not wish to change character encoding for the entire server, but only one site (or only one directory) then this is possible to do using .htaccess.

AddDefaultCharset UTF-8

If you only wish to do this to php or htm files (and not all files)

<FilesMatch "\.(htm|php)$">
AddDefaultCharset UTF-8

If you wish to modify the mime-type as well as the encoding (on html files in this example)

AddType 'text/html; charset=UTF-8' html

3 thoughts on “Apache2 changing charset using .htaccess

  1. Pingback:  at the top of the page (UTF-8 BOM) « Jontas blog *thingy*

  2. Pingback: HTML: UTF-8 encoding « Jontas

  3. Pingback: Apache2 unseting AddDefaultCharset (via .htaccess) « Jontas

Comments are closed.