LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > General > add charset to http header using htaccess

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2012, 12:14 AM
helenp helenp is offline
New Member
 
Join Date: Mar 2012
Posts: 7
Default add charset to http header using htaccess

Hi I been trying to add charset= utf-8 using htaccess.
It works on my php files and if I add AddDefaultCharset UTF-8 that I read is supported by Litespeed I get for the php files this http header:
Content-Type => text/html; charset=UTF-8
However it does not work on .css or .js files, I get this as header only:
Content-Type => text/css

I spoked to the host and he think its due to the gzipping of the files, but also the static content in the php files is being gzipped.

Should this work on .css files or can it be done in another way?

I am preparing my web for mobile devices and an error I get from w3s mobile checker is that my .css file does not have charset utf-8 in the http header, so I would like this fixed.

Thanks in advance
Helen

Last edited by helenp; 03-14-2012 at 12:19 AM.. Reason: Was cut
Reply With Quote
  #2  
Old 03-14-2012, 12:56 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,216
I did simple tests(phpinfo.php) on apache and lsws, lsws is compatible with apache in this regards.

refer apache document:
http://httpd.apache.org/docs/2.0/mod...defaultcharset
AddDefaultCharset On|Off|charset
works.

please note in the document:
"This directive specifies a default value for the media type charset parameter (the name of a character encoding) to be added to a response if and only if the response's content-type is either text/plain or text/html. "

so AddDefaultCharset only affect text/plain or text/html, not affect text/css
Reply With Quote
  #3  
Old 03-14-2012, 02:37 AM
helenp helenp is offline
New Member
 
Join Date: Mar 2012
Posts: 7
Quote:
Originally Posted by NiteWave View Post
I did simple tests(phpinfo.php) on apache and lsws, lsws is compatible with apache in this regards.

refer apache document:
http://httpd.apache.org/docs/2.0/mod...defaultcharset
AddDefaultCharset On|Off|charset
works.

please note in the document:
"This directive specifies a default value for the media type charset parameter (the name of a character encoding) to be added to a response if and only if the response's content-type is either text/plain or text/html. "

so AddDefaultCharset only affect text/plain or text/html, not affect text/css
Thanks, I tried all in this apache link:
http://www.askapache.com/htaccess/se...-htaccess.html
and non did work.
So how can I set charset for a .css files?
Would any of these work?
<filesMatch "\.(htm|html|css|js)$">
ForceType 'text/html; charset=UTF-8'
</filesMatch>

<filesMatch "\.(htm|html|css|js)$">
AddDefaultCharset UTF-8
</filesMatch>

I get this error at w3s mobilechecker:
One of the resources required to render the page (most likely a CSS style sheet) does not declare its encoding as UTF-8 in
an HTTP Content-Type header. Check that its content is properly encoded, and consider declaring its encoding at the HTTP level.

So can it be done?
Regards,
Helen
Reply With Quote
  #4  
Old 03-14-2012, 02:53 AM
helenp helenp is offline
New Member
 
Join Date: Mar 2012
Posts: 7
I also tried this:
AddType 'text/css; charset=UTF-8' .css
and it does not work
Many says this works in apache:
AddCharset utf-8 .css .js
But I read AddCharset is not supported in LiteSpeed, or at least was not in the list I saw as supported
Reply With Quote
  #5  
Old 03-14-2012, 03:47 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
upcoming 4.1.12 release will support

AddType 'text/css; charset=UTF-8' .css

and
AddDefaultCharset UTF-8

will work for context type starting with "text/", so, it can cover .css, but not .js.
Reply With Quote
  #6  
Old 04-09-2012, 02:47 PM
helenp helenp is offline
New Member
 
Join Date: Mar 2012
Posts: 7
Quote:
Originally Posted by mistwang View Post
upcoming 4.1.12 release will support

AddType 'text/css; charset=UTF-8' .css

and
AddDefaultCharset UTF-8

will work for context type starting with "text/", so, it can cover .css, but not .js.
Hi again,
My host have now upgraded to 4.1.12,
I tried both of previous and none worked for the ,css file.
Is it supported by 4.1.12?
Reply With Quote
  #7  
Old 04-15-2012, 01:10 AM
helenp helenp is offline
New Member
 
Join Date: Mar 2012
Posts: 7
Does the 4.1.12 release support
AddType 'text/css; charset=UTF-8' .css
and
AddDefaultCharset UTF-8 as said before in this thread?
Or am I or the host doing something wrong?
Would appreciate an answer, thanks.
Reply With Quote
  #8  
Old 04-15-2012, 02:19 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,216
just tested the latest 4.1.12, they are working as expected.

doing a force-reinstall, to be sure it's the latest version.
Reply With Quote
Reply

Tags
header htaccess charset

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:46 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.