On a centos Server 6.5, apache 2.2.15 is it possible to server multiple charsets to different virtual hosts?

I know that setting the default Charset is done by adding into the httpd.conf file:

AddDefaultCharset UTF-8

However some of the websites we have need to be encoded using ISO-8859-1 but the other websites that are served by Symfony need to be encoded with UTF-8. Is it possible to add a default charset per virtual host or does this need to be done using .htaccess files?

  • Whatever you put in .htaccess files can be put into separate site vhosts. – Peter Dec 5 '14 at 13:51

You can specify the default charset per directory or vhost, see httpd.apache.org.

In short:

<Directory /some/dir>
    CharsetDefault ISO-8859-1

You'll also need to ensure that the mod_charset_lite module is enabled.

  • Is it the same for Apache 2.4? – user2513149 Sep 10 '17 at 11:58
  • Yes, follow the httpd.apache.org link and change the 2.2 in the URL to 2.4, it's basically the same. – wurtel Nov 1 '17 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.