.htaccess AddCharset

Your feed appears to be encoded as "utf-8", but your server is reporting "US-ASCII"

 

cdl_capture_2011-04-07-03_ 000

Problem: When you run your feed through FeedValidator you receive an error similar to:

Your feed appears to be encoded as “utf-8”, but your server is reporting “US-ASCII”

Answer: What this means is that your server is configured to automatically send out your .php files marked as “US-ASCII” text.  This conflicts with what you have set as the encoding in your feed.

If you are running in an Apache-based webserver, you can tell your server to deliver all of your .php files (which would include everything served through ExpressionEngine) marked as a particular character set/encoding.

First, you need a .htaccess file in your main site directory.  Inside that file, place this, where you specify the character set you want to use:

AddCharset UTF-8 .php


http://www.askapache.com/htaccess/setting-charset-in-htaccess.html

.htaccess Charset Answer

You can try these, 1 at a time 🙂 Using FilesMatch and Files in htaccess

AddDefaultCharset UTF-8
<FilesMatch "\.(htm|html|css|js)$">
ForceType 'text/html; charset=UTF-8' 
</FilesMatch>
<FilesMatch "\.(htm|html|css|js)$">
AddDefaultCharset UTF-8
</FilesMatch>
AddCharset UTF-8 .html
AddType 'text/html; charset=UTF-8' html 

The method I personally use on all my sites is to use the AddDefaultCharset directive in the web root .htaccess file:

AddDefaultCharset UTF-8

This will add the following header to the server output of your text/html pages. Content-Type: text/html; charset=UTF-8

NOTE: The following meta tag is commonly used to do this same thing, so if you use this .htaccess method you will no longer need to include that meta tag, which is less code and thats always a good thing.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Leave a comment