htaccess UTF-8 encoding for .html, .css, .js - Whats the best way?

时光毁灭记忆、已成空白 提交于 2019-11-30 07:24:33

问题


For yslow page speed I want to remove my meta tag and put my encoding into the .htaccess file. Below are all the ways to do it I have read about. Which is the preferred way? Also is the language setting a good idea too - and if out side of the filesmatch will it apply to all file types?

1) https://github.com/jancbeck/My-Wordpress-Boilerplate/blob/master/htaccess.txt

AddDefaultCharset utf-8
AddCharset utf-8 .html .css .js
DefaultLanguage en-US

vs

2) http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html

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

vs

3) I suspect this is all that's needed. But untested.

AddCharset UTF-8 .html .css .js
DefaultLanguage en-US

回答1:


I think

AddDefaultCharset utf-8

is enough for all.

Maybe better way is set encoding to files, which are using different charset than default.



来源:https://stackoverflow.com/questions/13380206/htaccess-utf-8-encoding-for-html-css-js-whats-the-best-way

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!