My server is set to UTF-8, but i'd like a specific folder to output a Content-Type HTTP header which says charset=Shift-JIS. I tried uploading an .htaccess file to the folder, containing AddDefaultCharset Shift-jis but that didn't work.
Asked
Active
Viewed 804 times
-1
-
What does "folder to be Shift-JIS" mean? That you'd like *its content* to actually be encoded in Shift-JIS? Or that you merely want to output a `Content-Type` HTTP header which says `charset=shift-jis`? – deceze Jun 27 '16 at 13:26
-
I was looking for the folder to output a content type HTTP header with charset=Shift-JIS. Thanks for pointing out! – sthg Jun 28 '16 at 07:37
2 Answers
1
Did you place your AddDefaultCharset
directive in an htaccess
located in the directory whose Charset you're trying to change? If not, please do so.
If you want all html files in that directory to have the charset, try
<FilesMatch "\.html?$">
ForceType 'text/html; charset=Shift-jis'
</FileMatch>
If that doesn't work, you could set the HTTP header directly with the following directive (in the same htaccess
)
<FilesMatch "\.html?$">
Header add Content-Type "text/html; charset=Shift-jis"
</FilesMatch>
You may need to add more FileMatch
containers for other file types, and adjust the MIME type within the header (eg: "text/css" or "application/javascript" for .css
and .js
files)

BeetleJuice
- 39,516
- 19
- 105
- 165
-
Yes, that's exactly what I did. I've tried uploading the htaccess file directly in the folder that I wanted encoded in Shift-jis. I'll give your recommendation a try. – sthg Jun 27 '16 at 03:05
-
0
According to @MiffTheFox Yes.
<Files ~ "\.html?$">
Header set Content-Type "text/html; charset=utf-8"
</Files>
please look at the original answer https://stackoverflow.com/a/913880/1431184

Community
- 1
- 1

printfmyname
- 983
- 15
- 30