如果文件index.html
不存在,它将列出目录中的文件,它使用iso-8859-1作为默认编码。
如果服务器是Apache,有没有办法将UTF-8设置为默认值?
在httpd.conf中添加(或者如果它已经存在的话进行更改):
AddDefaultCharset utf-8
把这个添加到你的.htaccess
:
IndexOptions +Charset=UTF-8
我试了只加在httpd.conf是无效的,还要同时加在.htaccess.
如果在没index.html时列出目录和html,可以在目录下添加HEARDER.html和README.html
[root@localhost html]# ls
anaconda centos CRAN debian debian-cd deepin deepin-cd epel help README.html ubuntu ubuntu-releases
由于时间问题,html未修改完成。发个截图
apache开启目录浏览模式
在httpd-autoindex.conf(在\Apache\conf\extra\httpd-autoindex.conf)
搜索IndexOptions,并且整行改为
IndexOptions FancyIndexing HTMLTable VersionSort NameWidth=* FoldersFirst Charset=UTF-8 SuppressDescription SuppressHTMLPreamble