设为首页收藏本站

全球主机交流论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: discuz
查看: 1097|回复: 0
打印 上一主题 下一主题

linux乱码解决

[复制链接]
  • TA的每日心情
    无聊
    2017-9-11 09:31
  • 签到天数: 176 天

    [LV.7]常住居民III

    跳转到指定楼层
    楼主
    发表于 2015-9-6 09:27:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    最近打算建立一个分享资源的网络空间,想使用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下如何设置文件目录列表的编码
    Submitted by admin on Thu, 12/03/2009 - 21:11
    Web
    来源地址: 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)
    The Charset keyword allows you to specify the character set of the generated page. The default is either ISO-8859-1 or UTF-8, depending on whether the underlying file system is unicode or not.
    Example:
    IndexOptions Charset=UTF-8

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


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


    使用IndexOptions FancyIndexing选项,
    当访问没有DirectoryIndex指定文档的目录时,启用该选项可以针对目录下不同类型的文档指定相对应的icon
    示例如下:
    编辑httpd.conf,把下列代码放于任意位置:
    IndexOptions FancyIndexing AddIcon /other/icons/exe.gif .bin .exe AddIcon /other/icons/dir.gif ^^DIRECTORY^^ AddIcon /other/icons/txt.gif .txt .php .PHP AddIcon /other/icons/html.gif .htm .html AddIcon /other/icons/image.gif .gif .jpg .bmp .png
    重启apache
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
    收藏收藏
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|小黑屋|Archiver|手机版|中国U网    

    GMT+8, 2024-5-7 09:05 , Processed in 0.069737 second(s), 21 queries .

    Powered by Discuz! X3.2

    © 2001-2013 Comsenz Inc.

    快速回复 返回顶部 返回列表