Posts tagged Change the default character set for Apache

Change the default character set for Apache

By default, on most of the linux systems  the default character set for Apache is  UTF-8.  But what if your web application requires a different character set .

Say, if  all of your sites are in Spanish Language then you would most likely  to change this to the Latin-1 character set (ISO-8859-1)  .


So, follow the below steps to  change default charset for apache


1 > For all domains

Open  the /etc/httpd/conf/httpd.conf  file and search  for line ::


AddDefaultCharset UTF-8 

and replace with  the charset of your choice for example with  ISO-8859-1


AddDefaultCharset ISO-8859-1 

if the above line does not  exists in httpd.conf file then add that line

And finally restart the apache/httpd service for the changes to  take effect.

To verify  the new default charset for apache  use the below command ::


[email protected] [~]# curl -I localhost
HTTP/1.1 200 OK
Date: Wed, 04 Apr 2012 06:40:49 GMT
Server: Apache
Last-Modified: Sat, 31 Mar 2012 15:11:54 GMT
Accept-Ranges: bytes
Content-Length: 111
Content-Type: text/html; charset=ISO-8859-1

2 >  For a Single domain


If you want to change the charset for only a single domain then add the code :: AddDefaultCharset ISO-8859-1 in  the .htaccess file under the document root for that domain.


[email protected][~]# vi .htaccess
AddDefaultCharset ISO-8859-1

That’s all you are done.