Set default charset for one cPanel account

Sometimes the text in our website has been placed on pages using different charsets than the standart one (UTF-8, generally), this can lead into issues while loading special characters for Spanish, Portuguese and other languages different than english. For those times you may need to tweak out the Apache default charset.

The default charset for Apache can be configured from two places:

    • Default httpd.conf file

Look for the AddDefaultCharset variable and set it to match your needs, example:

AddDefaultCharset ISO-8859-1

Restart Apache to apply the changes:

service httpd restart
    • .htaccess for one cPanel account in particular: just place this inside your .htaccess file in your public_html directory:
AddDefaultCharset ISO-8859-1

Reload your webpage and it should be ready. Now all your files inside public_html and the subfolders will use the new configured charset.

If you are still facing issues with your characters then it may not be an issue with Apache, but with your MySQL charset, that can be tweaked using phpmyadmin, we will cover that in another tutorial.

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *