Change Charset Response Header for Apache Indexes Change Charset Response Header for Apache Indexes apache apache

Change Charset Response Header for Apache Indexes


Turns out that Apache has a separate setting for encoding the indexes it generates. You can set the charset for an index by adding this line to an .htaccess file, placed in the directory where your index will be generated:

IndexOptions Charset=UTF-8

This fixed it for me!


AddDefaultCharset is used when a response header's content-type is text/plain or text/html
In .htaccess or httpd.conf you can add:

AddDefaultCharset utf-8

AddCharset is to define the character set for any given file extension.

In .htaccess or httpd.conf you can add:

AddCharset utf-8 .html .css .php .txt .js

In PHP (before any page content is output):

<?phpheader('Content-Type: text/html; charset=utf-8'); 

If you HAVE to use the HTML meta tag (cannot edit config or htaccess) it must be the first thing that follows the <head>
Reference: Best Practice: Get your HEAD in order

<head><meta http-equiv="content-type" content="text/html; charset=UTF-8">


For html
Put the following between your <head> </head> tags:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

For xhtml
Put the following between your <head> </head> tags:

<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>

Begin your php files with:

<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ?>