Apache 中文目录浏览乱码解决办法

来源:互联网 发布:三星pc软件手机版本 编辑:程序博客网 时间:2024/04/30 13:59
http://www.cnitblog.com/201/archive/2010/04/14/65277.html

最近打算建立一个分享资源的网络空间,想使用FTP,但是又觉得不算好用。于是就直接使用Apache的Indexes参数来搭建一个可浏览目录的虚拟主机,好处在于可以直接在浏览器中以网页形式展现。

     但是按照Apache的文档来配置就出现问题了。经过测试,如果目录中含有中文文件或者中文目录的时候,在IE下显示乱码,于是在浏览器中查看其编码发现它默认使用ISO-8859-1编码,手动选择GB2312后就能正常显示。看来是Apache Indexes在处理中文的时候的编码不正确。

     仔细研究其说明文档,其中介绍,可以在Apache配置文件中为Indexes指定特定的编码,我们能够修改配置文件让其支持中文。具体办法如下:

      在配置文件中添加:

     IndexOptions Charset=GB2312

    这样这样就能解决Apache autoindex模块中文乱码问题了。


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

http://tilt.lib.tsinghua.edu.cn/node/528

Apache 2下如何设置文件目录列表的编码

来源地址: http://httpd.apache.org/docs/2.0/mod/mod_autoindex.html

IndexOptions Directive
Description: Various configuration settings for directory indexing
Syntax: IndexOptions [+|-]option [[+|-]option] ...
Context: server config, virtual host, directory, .htaccess
Override: Indexes
Status: Base
Module: mod_autoindex

The IndexOptions directive specifies the behavior of the directory indexing. Option can be one of

Charset=character-set (Apache 2.0.61 and later)
TheCharset keyword allows you to specify the character set of thegenerated page. The default is either ISO-8859-1 or UTF-8, depending onwhether the underlying file system is unicode or not.
Example:
IndexOptions Charset=UTF-8

Apache2默认使用ISO-8859-1或UTF-8编码。上传的文档目录和文件名称则使用了GBK编码字符,导致每次需要手工选择编码之后,才能正确显示其列出的目录和文件名列表。为了设置以GBK编码显示目录和文件名列表,可以在Apache 2中设置上述选项:
IndexOptions Charset=GBK


++++++++++++++++++++++++++++++++++++++++++++++++++++++

http://blog.csdn.net/jom_ch/archive/2008/06/25/2585509.aspx

使用IndexOptions FancyIndexing选项,

当访问没有DirectoryIndex指定文档的目录时,启用该选项可以针对目录下不同类型的文档指定相对应的icon

示例如下:

编辑httpd.conf,把下列代码放于任意位置:

IndexOptions FancyIndexingAddIcon /other/icons/exe.gif .bin .exeAddIcon /other/icons/dir.gif ^^DIRECTORY^^AddIcon /other/icons/txt.gif .txt .php .PHPAddIcon /other/icons/html.gif .htm .htmlAddIcon /other/icons/image.gif .gif .jpg .bmp .png

重启apache



<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(1177) | 评论(0) | 转发(1) |
0

上一篇:c语言中的 顺序点

下一篇:信号屏蔽函数

相关热门文章
  • linux 常见服务端口
  • xmanager 2.0 for linux配置
  • 【ROOTFS搭建】busybox的httpd...
  • openwrt中luci学习笔记
  • 什么是shell
  • linux dhcp peizhi roc
  • 关于Unix文件的软链接
  • 求教这个命令什么意思,我是新...
  • sed -e "/grep/d" 是什么意思...
  • 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
原创粉丝点击